Sign in Join

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

Mailing lists / fpc-pascal / 2000-11

Re: Delay replacement...

5 messages · 4 people · –

Reply by email Subscribe to this list Your subscription

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

Johann Glaser
to Rainer Hantsch: Hi, everybody! I am currently writing some CGI programs which need exclusive access to…

Hi!

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

Delay is defined as

Procedure Delay(DTime: Word);
{
  Wait for DTime milliseconds.
}
Begin
  Select(0,nil,nil,nil,DTime);
End;

You can use this very small procedure and define your own "Delay"-Procedure. "Select" will suspend the process until DTime Milliseconds are over, so all other processes get execution time.

Bye
Hansi

Johann Glaser Vienna University of Technology Electrical Engineering http://stud3.tuwien.ac.at/~e9825761/index.html

Reply by email

Rainer Hantsch

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 10 lines
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...

Maybe you should try file-locking?
FLOCK(....)
See docs

*************************************
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

Peter Vreman
Show quoted text 9 lines
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?

Use Sleep() or Select()

Reply by email

Rainer Hantsch
to Johann Glaser: Hi! Delay is defined as Procedure Delay(DTime: Word); { Wait for DTime milliseconds. }…

Thanks a lot, it works fine...

On Mon, 27 Nov 2000, Johann Glaser wrote:
: Hi!
: > How can I force a scheduling to sleep for a while? : Delay is defined as
:
: Procedure Delay(DTime: Word);
: { Wait for DTime milliseconds }
: Begin
: Select(0,nil,nil,nil,DTime);
: End;
:
: You can use this very small procedure and define your own : "Delay"-Procedure. "Select" will suspend the process until DTime : Milliseconds are over, so all other processes get execution time. :
: Bye
: Hansi
:
: --
: Johann Glaser
: Vienna University of Technology
: Electrical Engineering
: http://stud3.tuwien.ac.at/~e9825761/index.html
:
: _______________________________________________
: fpc-pascal maillist -
: http://lists.freepascal.org/mailman/listinfo/fpc-pascal :

Reply by email