Re: [LIP] usleep(): Not sleeping.
Arun Venkataswamy <[email protected]>
| Newsgroups | gmane.user-groups.linux.india.programmers |
|---|---|
| Message-ID | <[email protected]> |
On Tue, 9 Nov 2004 13:46:47 +0530 (IST), H S Rai <[email protected]> wrote: > I am trying to sun my previous programms written in Turbo C, which > include small game and sound program applications. I was trying to > find delay(time_in_milli_sec) function and found usleep(). > > But to is not doing anything. In program I used usleep(20000), but > program execution took only 0.03 sec. > > Is usleep right function to provide delay for predetermined time or > something better (a least workable) is there. Hi, If your timing requirement is not very precise and if you don't mind wasting processor cycles, you can use the 'clock()' function effectively to create the delay. The code would be some thing like... c1 = c2 = clock(); while ((float)(c2-c1)/CLOCKS_PER_SEC < delaytime) c2 = clock(); 'delaytime' is a float and it represents 'seconds' and not 'milliseconds' regards, V.Arun -- Arun Venkataswamy ------------------------------------------------------- This SF.Net email is sponsored by: Sybase ASE Linux Express Edition - download now for FREE LinuxWorld Reader's Choice Award Winner for best database on Linux. http://ads.osdn.com/?ad_id=5588&alloc_id=12065&op=click