By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
464,706 Members | 1,298 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 464,706 IT Pros & Developers. It's quick & easy.

sleep VS delay

P: 3
Which is the best one to use sleep or delay ( for a delay in the process ) .As i understand use of sleep, allows the kernel to schedule the process.

And if a sleep of microseconds is used, and the kernel schedules at this time, will it takes care to reschedule the interrupted process, back in the requested amount of sleep the process had asked for ( as the other process which the kernel witched to may take long time to give back the control).

Jul 31 '08 #1
Share this Question
Share on Google+
2 Replies

Expert 100+
P: 315
If we're talking C here, you may want to have a look at nanosleep(2). The man page says something about 'more easily continuing' the sleep in case a signal has been received.

If you can afford to spent the CPU cycles, you can also implement a busy wait using gettimeofday(2). Depends on what you need.

Aug 3 '08 #2

P: 62
Since I don't know about the context or the language I can't be much more help except to say that if it is C and you want it to be more precise, try using select. Man select should give you a feel for it and then google should provide the rest.

Aug 7 '08 #3

Post your reply

Sign in to post your reply or Sign up for a free account.