Path: utzoo!censor!geac!torsqnt!news-server.csri.toronto.edu!cs.utexas.edu!wuarchive!zaphod.mps.ohio-state.edu!uakari.primate.wisc.edu!uflorida!haven!adm!smoke!gwyn From: gwyn@smoke.brl.mil (Doug Gwyn) Newsgroups: comp.unix.questions Subject: Re: Standard way to yield cpu Message-ID: <14580@smoke.brl.mil> Date: 26 Nov 90 22:19:47 GMT References: Organization: U.S. Army Ballistic Research Laboratory, APG, MD. Lines: 12 In article scott@next-8.gac.edu (Scott Hess) writes: >Is there any method under standard Unix to yield up the CPU so that other >tasks can run for a time? I speculate that a call to sleep() with 0 >timeout _might_ do it, but someone may just have optimized that part . . . >I could do testing, but it would not be very conclusive, as I'd have no >way of telling whether another task actually ran. Basically, any system call provides a rescheduling opportunity. If you want to minimize the overhead, getpid() is the cheapest possible system call. However, other system calls such as select() will already be providing reschedule opportunities in most cases. If you really want to delay the suspended process, sleep(nonzero) is the way to do it.