Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.programming.threads > #135

Re: pthread question

Newsgroups comp.programming.threads
From Geoff Clare <geoff@clare.See-My-Signature.invalid>
Subject Re: pthread question
References <b3bf253c-0285-4eeb-8d64-e01fa16c5f0c@f15g2000pro.googlegroups.com> <39abb345-ad69-453d-89da-29ee8e6e94f2@z15g2000prn.googlegroups.com>
Date 2011-05-10 13:47 +0100
Message-ID <aoon98-odg.ln1@leafnode-msgid.gclare.org.uk> (permalink)
Organization Zen Internet

Show all headers | View raw


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 <netnews@gclare.org.uk>

Back to comp.programming.threads | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

pthread question p6 c6d6 <p6c6d6@gmail.com> - 2011-05-08 21:28 -0700
  Re: pthread question Vaclav Haisman <v.haisman@sh.cvut.cz> - 2011-05-09 07:11 +0200
  Re: pthread question Joshua Maurice <joshuamaurice@gmail.com> - 2011-05-09 11:49 -0700
    Re: pthread question David Schwartz <davids@webmaster.com> - 2011-05-09 12:24 -0700
      Re: pthread question Joshua Maurice <joshuamaurice@gmail.com> - 2011-05-09 14:22 -0700
        Re: pthread question "Chris M. Thomasson" <cristom@charter.net> - 2011-05-09 15:33 -0700
        Re: pthread question David Schwartz <davids@webmaster.com> - 2011-05-10 01:22 -0700
    Re: pthread question Geoff Clare <geoff@clare.See-My-Signature.invalid> - 2011-05-10 13:47 +0100
      Re: pthread question Alexander Terekhov <terekhov@web.de> - 2011-05-10 17:53 +0200
        Re: pthread question Geoff Clare <geoff@clare.See-My-Signature.invalid> - 2011-05-11 13:46 +0100
          Re: pthread question Alexander Terekhov <terekhov@web.de> - 2011-05-11 16:19 +0200
            Re: pthread question Geoff Clare <geoff@clare.See-My-Signature.invalid> - 2011-05-12 13:26 +0100
              Re: pthread question Alexander Terekhov <terekhov@web.de> - 2011-05-12 15:28 +0200
                Re: pthread question Geoff Clare <geoff@clare.See-My-Signature.invalid> - 2011-05-13 14:00 +0100
                Re: pthread question Alexander Terekhov <terekhov@web.de> - 2011-05-13 22:59 +0200
                Re: pthread question Geoff Clare <geoff@clare.See-My-Signature.invalid> - 2011-05-16 13:28 +0100

csiph-web