sleep VS delay

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • virupax
    New Member
    • May 2008
    • 3

    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
  • arne
    Recognized Expert Contributor
    • Oct 2006
    • 315

    #2
    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

    Comment

    • edwardrsmith
      New Member
      • Feb 2008
      • 62

      #3
      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

      Comment

      Working...