[fpc-pascal]Total locking...

Rainer Hantsch rainer at hantsch.co.at
Tue Nov 28 09:50:06 CET 2000


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: office at hantsch.co.at
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 <rainer at hantsch.co.at>
To: Free Pascal Group <fpc-pascal at lists.freepascal.org>
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: office at hantsch.co.at
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
-----------------------------------------------------------------






More information about the fpc-pascal mailing list