Does 4GL SLEEP take CPU resources under UNIX?
Posted in 2000
Topics: Connectivity: ESQL/C, 4GL & Embedded SQL, Platform-Specific Issues
If I have a continuously running 4GL program with a SLEEP at the end of each pass, is the program still costing me in CPU time during SLEEP (versus in C/C++ under Windows NT for example, where you can yield back to Windows for it to do other tasks)? In other words, is SLEEP any better than doing a FOR loop in this regard??? Informix 4GL 7.20 under Solaris 7. Thanks, Hal Hal Maner M Systems International, Inc. P. O. Box 51125 Durham, NC 27717 Phone: (919) 493-6012 ext. 15 Fax: (919) 493-8837 E-mail: hmaner@msystemsintl.com www.msystemsintl.com
I don't know, however, you can always code a 'C' sleep system call or call to select() with a timer and make the function 4GL callable to get a true sleep. Art S. Kagel Hal Maner wrote: > If I have a continuously running 4GL program with a SLEEP at the end of each > pass, is the program still costing me in CPU time during SLEEP (versus in > C/C++ under Windows NT for example, where you can yield back to Windows for > it to do other tasks)? > > In other words, is SLEEP any better than doing a FOR loop in this regard??? > > Informix 4GL 7.20 under Solaris 7. > > Thanks, > Hal > > Hal Maner > M Systems International, Inc. > P. O. Box 51125 > Durham, NC 27717 > Phone: (919) 493-6012 ext. 15 > Fax: (919) 493-8837 > E-mail: hmaner@msystemsintl.com > www.msystemsintl.com
Hal Maner wrote: > If I have a continuously running 4GL program with a SLEEP at the end of each > pass, is the program still costing me in CPU time during SLEEP (versus in > C/C++ under Windows NT for example, where you can yield back to Windows for > it to do other tasks)? > > In other words, is SLEEP any better than doing a FOR loop in this regard??? SLEEP is implemented as a call to the C function sleep(), which uses no CPU time while it is waiting for the time to elapse. This is infinitely preferable to a FOR loop, unless you need to wait for fractional seconds. Actually, even then, a FOR loop is a very bad idea (you'd have to retune it each time you improve your hardware, if nothing else). But you could arrange to call one of the sub-second resolution sleep functions (system calls) from some C code that could be called from I4GL. -- Jonathan Leffler (jleffler@informix.com, jleffler@earthlink.net) Guardian of DBD::Informix v1.00.PC1 -- see http://www.perl.com/CPAN #include <disclaimer.h>