home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #18 / NN_1992_18.iso / spool / comp / unix / programm / 4385 < prev    next >
Encoding:
Internet Message Format  |  1992-08-20  |  1.7 KB

  1. Path: sparky!uunet!zaphod.mps.ohio-state.edu!sdd.hp.com!swrinde!news.dell.com!uudell!bigtex!texsun!ttsi!mse
  2. From: mse@ttsi.lonestar.org (Mark Evans)
  3. Newsgroups: comp.unix.programmer
  4. Subject: Re: Yielding a Timeslice
  5. Message-ID: <1992Aug20.132824.7238@ttsi.lonestar.org>
  6. Date: 20 Aug 92 13:28:24 GMT
  7. References: <1992Aug19.184837.24219@news.weeg.uiowa.edu>
  8. Organization: st
  9. Lines: 26
  10.  
  11. In article <1992Aug19.184837.24219@news.weeg.uiowa.edu> schwaigr@news.weeg.uiowa.edu (Jim Schwaiger) writes:
  12. >Is there a standard (or commonly accepted) way for a program to yield
  13. >its timeslice?  I have a program which checks on a condition in shared
  14. >memory and would like to sleep (for less than 1 second) if that condition
  15. >is not met, rather than waiting in the "hot" loop.
  16. >
  17. >Jim Schwaiger
  18.  
  19. I asked the same question recently.  There is no universal facility
  20. across unices.  There is a Posix-defined facility named yield()
  21. that some systems support.  If you are running on SVR4, you might 
  22. also look at priocntl(2).  It advertises, for real-time class processes,
  23. the ability to "go to the back of the scheduling queue at the same
  24. priority by resetting its rt_pri value to its current real-time
  25. priority value."  An associate played with this briefly and observed
  26. some very screwy behavior---a long 30ms average delay before returning.
  27. We have no idea what's going on.  
  28.  
  29. Also look at select() (BSD) or poll() (SVR[34]) which you can use
  30. to implement a higher granular sleep based upon the system tick
  31. frequency, which is usually 60 or 100 HZ.  
  32. -- 
  33. Mark S. Evans                 Tandem Telecommunications Systems Inc.
  34. Phone: 214-516-6201           1255 W 15th St.
  35. Fax:   214-516-6805           Plano, TX 75075
  36. Mail:  mse@ttsi.lonestar.org
  37.