|
The following "C" program allows you to pass in the number of microseconds to wait (1,000,000 = one second). So for 1/100 of a second, should be about 10,000 microseconds..... I'm sure that if my math is wrong someone will point it out :).... It will also pass back a return code if the sleep failed for some reason. You should probably expect a -1 back if you are waiting less than one second. #include <unistd.h> #include <decimal.h> void cp_delay(decimal(9,0) *duration, decimal(9,0) *return_code) { /* 400 uses four byte integers */ /* should be large enough to hold 4294967296 */ /* or approximately 4295 seconds */ /* or approximately 72 minutes */ /* or over 1 hour */ int number_of_microseconds; int whole_seconds; int fractional_seconds; *return_code = 0; number_of_microseconds = *duration; whole_seconds = number_of_microseconds / 1000000; fractional_seconds = number_of_microseconds - (whole_seconds * 1000000); /* sleep == -1 if sleep failed */ if (sleep(whole_seconds) == -1) *return_code = 1; /* usleep == -1 if usleep failed */ if (usleep(fractional_seconds) == -1) *return_code = 2; return; } ****************** End of data *********************************** Ross Hartford Cothern Computer Systems, Inc. 3760 I-55 North, Suite 200 Jackson, MS 39211 Phone: (601) 718-0803 Support: (888) 222-5577 Fax: (601) 969-1184 email: mailto:rossh@ccslink.com web: http://www.ccslink.com -----Original Message----- From: midrange-l-bounces@midrange.com [mailto:midrange-l-bounces@midrange.com]On Behalf Of Dan Rasch Sent: Friday, January 31, 2003 10:16 AM To: Midrange Systems Technical Discussion Subject: Delay less than a second Does anyone know how to delay a job less than a second? One-hundredth of a second would be ideal. Dan Rasch - because if the human species concentrated on the really important things in life, there would be a shortage of fishing poles! IBM Certified twice....... but still a couple PTFs away from Nirvana. _______________________________________________ This is the Midrange Systems Technical Discussion (MIDRANGE-L) mailing list To post a message email: MIDRANGE-L@midrange.com To subscribe, unsubscribe, or change list options, visit: http://lists.midrange.com/mailman/listinfo/midrange-l or email: MIDRANGE-L-request@midrange.com Before posting, please take a moment to review the archives at http://archive.midrange.com/midrange-l.
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.