*BSD News Article 23812


Return to BSD News archive

Newsgroups: comp.unix.bsd
Path: sserve!newshost.anu.edu.au!munnari.oz.au!news.Hawaii.Edu!ames!elroy.jpl.nasa.gov!usc!math.ohio-state.edu!cyber2.cyberstore.ca!nntp.cs.ubc.ca!unixg.ubc.ca!acs.ucalgary.ca!cuugnet!heinlein!thompson
From: thompson@sun.cuug.ab.ca (Bruce Thompson 295-5967(w) or 229-3370(h))
Subject: Re: How to cause preemption under Unix???
Sender: usenet@cuug.ab.ca
Message-ID: <THOMPSON.93Nov13000424@sun.cuug.ab.ca>
In-Reply-To: olson@osiris's message of 10 Nov 93 20:02:47 PST
Date: Sat, 13 Nov 1993 07:04:24 GMT
References: <1993Nov10.200248.7409@nic.csu.net>
Organization: Calgary UNIX User's Group
Lines: 19

In article <1993Nov10.200248.7409@nic.csu.net> olson@osiris (Brian Olson) writes:

   Does anyone know of a way (system call, etc.) that a running 
   process may voluntarily give-up the CPU?  That is, is there a way
   for the active process to cause a context switch to be performed,
   while still leaving itself in the ready queue?

While not strictly speaking precisely what you asked for, I've used
usleep(3) for that purpose. usleep with an argument of 0 should
effectively wake your process back up immediately, at the back of the
ready queue of course.

	Cheers,
	Bruce.
--
Bruce Thompson,		      |I do not speak for CUUG, ACTC Technologies,
Software Development Engineer,|Renegade Legion nor NAPRA, just myself.
ACTC Technologies Inc.	      |"So this is it, we're going to die!"
Renegade Legion, NAPRA #473   |		-- Dent Arthur Dent