X-FeedAbuse: http://nntpfeed.proxad.net/abuse.pl feeded by 88.191.16.109 Path: csiph.com!x330-a1.tempe.blueboxinc.net!aioe.org!news.dougwise.org!nntpfeed.proxad.net!nospam.fr.eu.org!usenet-fr.net!fdn.fr!feeder1-2.proxad.net!proxad.net!feeder2-2.proxad.net!zen.net.uk!hamilton.zen.co.uk!reader02.news.zen.co.uk.POSTED!not-for-mail Newsgroups: comp.programming.threads From: Geoff Clare Subject: Re: pthread question References: <39abb345-ad69-453d-89da-29ee8e6e94f2@z15g2000prn.googlegroups.com> User-Agent: XPN/1.2.6 (Street Spirit ; Linux) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Date: Tue, 10 May 2011 13:47:38 +0100 Message-ID: Lines: 36 Organization: Zen Internet NNTP-Posting-Host: 896a40d8.news.zen.co.uk X-Trace: DXC=USW^QWlfEiD2[5KGR9O9IJ^X1YWB^a70O X-Complaints-To: abuse@zen.co.uk Xref: x330-a1.tempe.blueboxinc.net comp.programming.threads:135 Joshua Maurice wrote: > AFAIK, the following is an entirely legitimate and POSIX conforming > implemention of pthread_yield: > int pthread_yield() { return 0; } There is no function called pthread_yield() in POSIX. I assume you mean sched_yield(). > That is, it can be implemented as a no-op. It would be contrary to the > "spirit" of pthread_yield, but no conforming portable program could > tell the difference. I think sched_yield() can be a no-op on implementations that don't support the TPS (_POSIX_THREAD_PRIORITY_SCHEDULING) option. If the TPS option is supported then POSIX has requirements on what sched_yield() does as part of the description of the SCHED_FIFO policy: 9. When a running thread issues the sched_yield() function, the thread becomes the tail of the thread list for its priority. (It also applies to SCHED_RR and SCHED_SPORADIC, as they are described by reference to SCHED_FIFO.) It should be possible to write a program that uses some SCHED_FIFO threads to detect whether sched_yield() "works". > It depends on the internals of the scheduler, and > that is something with POSIX did not standardize. POSIX doesn't standardise internals, but it does standardise how threads with the above mentioned scheduling policies are scheduled. -- Geoff Clare