Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2000-11

Total locking...

2 messages · 2 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Rainer Hantsch

Hi, everybody!

Another question to the same programming needs:

I need to do an absolute 100% blocking LOCKING.

I want to create a file and put such strong locks on it, that no other program can overcome this lock.
All related other programs test for presence of this file. If existing, they must be blocked until it is away.

Currently I simply create a text-file, add FLock(File,LOCK_EX); and keep it open.
Is this enough?

Is it possible that another instance of the same program can take over this file in some situations? Or will it always get an IOResult Error?

--> Linux!!

Ing. Rainer Hantsch

\\|// Ing. Rainer HANTSCH - Hardware + Software (o o) Your Partner - Your Supplier - Your Friend! --oOOo-(_)-oOOo-------------------------------------------------- Ing. Rainer HANTSCH | e-Mail:
Khunngasse 21/20 | www : http://www.hantsch.co.at A-1030 Vienna | Tel. : ++43 - 1 - 7988538 0 ---------------------| Fax : ++43 - 1 - 7988538 18 ** AUSTRIA ** | Mobile: ++43 - 663 - 9194382 -----------------------------------------------------------------

---------- Forwarded message ----------
Date: Tue, 28 Nov 2000 09:43:48 +0100 (CET)
From: Rainer Hantsch
To: Free Pascal Group
Subject: Delay replacement...

Hi, everybody!

I am currently writing some CGI programs which need exclusive access to particular files. (Never must these files be accessed from more that one instance of this program, but -- because of the nature of cgi -- it can theoretically be launched unlimited times...

So I use a lock file which I place in /tmp/ and the program tests its presence and waits until it is vanished, then it creates one by itself...

Well, but:
When I loop infinitely, always testing the presence, I force a dramatic CPU load. So I tried to implement crt (or ncrt) to have delay() available and to free up hereby the CPU for some seconds.
This shall allow the other instance of the program to get more CPU power and finish quicker.

However, when I use *crt, the program does very nasty things, but not what I want, so I cannot use crt/ncrt.

How can I force a scheduling to sleep for a while?

Ing. Rainer Hantsch

\\|// Ing. Rainer HANTSCH - Hardware + Software (o o) Your Partner - Your Supplier - Your Friend! --oOOo-(_)-oOOo-------------------------------------------------- Ing. Rainer HANTSCH | e-Mail:
Khunngasse 21/20 | www : http://www.hantsch.co.at A-1030 Vienna | Tel. : ++43 - 1 - 7988538 0 ---------------------| Fax : ++43 - 1 - 7988538 18 ** AUSTRIA ** | Mobile: ++43 - 663 - 9194382 -----------------------------------------------------------------

Reply by email

Ziegenhorn Tourism Database
Show quoted text 18 lines
Hi, everybody! Another question to the same programming needs: I need to do an absolute 100% blocking LOCKING. I want to create a file and put such strong locks on it, that no other program can overcome this lock. All related other programs test for presence of this file. If existing, they must be blocked until it is away. Currently I simply create a text-file, add FLock(File,LOCK_EX); and keep it open. Is this enough? Is it possible that another instance of the same program can take over this file in some situations? Or will it always get an IOResult Error?

A rm will delete the file anyway. That means, if you have all programs under controll which access this file, and all of them use (File,LOCK_EX) it will do the job.

*************************************
Ziegenhorn Tourism Database
P.O. Box 16 45
76726 Germersheim, Germany
Tel: +49-7274-2759 Fax: +49-7274-3631
http://www.ziegenhorn.com
*************************************

Reply by email