473,386 Members | 1,795 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

sleep VS delay

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).

Thanks
Jul 31 '08 #1
2 6124
arne
315 Expert 100+
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.

HTH,
arne
Aug 3 '08 #2
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.

Edward
Aug 7 '08 #3

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

Similar topics

4
by: Xaradas | last post by:
How can I suspend the execution of a script for x seconds? Does exists something like sleep(x)? Thanks. ------------------------------------ "Computer Science is no more about computers ...
7
by: John | last post by:
Thanks. I am writing a C++ code on Linux and Sun OS platform. How to make a procedure sleep or delay? Thanks again. "John Carson" <donaldquixote@datafast.net.au> wrote in message...
21
by: Alo Sarv | last post by:
Hi From what I have understood from various posts in this newsgroup, writing event loops pretty much comes down to this: while (true) { handleEvents(); sleep(1); // or _sleep() or...
1
by: Robert Huie | last post by:
Hi all, I'm trying to use asp.net to code a chat window and I would like to make the http request delay as long as possible till the process/thread detects a new incoming message. basically...
0
by: Max | last post by:
This is a follow-up on my previous thread concerning having the program wait for a certain date and time and then executing some code when it gets there. My question is; can I use the Sleep...
2
by: andychambers2002 | last post by:
I've written a simple Timer class that allows you to extend it and then implement onMinuteChange, onHourChange etc methods which will be executed on each new minute/hour respectively. It works...
3
by: Steve Lowe | last post by:
Hi, I'm getting into VB.net with the help of a few books, but have got a problem grasping how to implement a system.timers.timer Only 1 of my 3 books mentions timers and that's a...
2
by: jrsjrs | last post by:
<?php echo "<BR><BR>A) Present time is:<BR>"; echo date('h:i:s') . "\n<BR>Delaying 5 seconds, new time is:<BR>"; sleep(5); echo date('h:i:s') . "\n<BR>"; ?> This first script delays 5...
13
by: Charles Zhang | last post by:
Sleep() function Sleep at lease 1 millisecond, there is a way to make a thread to sleep less than a millisecond? One way I know of is using performance counter which is not really sleep ( loop and...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.