public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Jakub Jelinek <jakub@redhat.com>
To: Paul Davis <paul@linuxaudiosystems.com>
Cc: Ingo Molnar <mingo@elte.hu>, linux-kernel@vger.kernel.org
Subject: Re: 2.6.X, NPTL, SCHED_FIFO and JACK
Date: Wed, 30 Jun 2004 12:57:56 -0400	[thread overview]
Message-ID: <20040630165756.GX21264@devserv.devel.redhat.com> (raw)
In-Reply-To: <200406301632.i5UGW3Ai011182@localhost.localdomain>

On Wed, Jun 30, 2004 at 12:32:03PM -0400, Paul Davis wrote:
> >One thing to note is that NPTL defaults to PTHREAD_INHERIT_SCHED
> >while LinuxThreads defaults to PTHREAD_EXPLICIT_SCHED.
> >So, if you care about what scheduling created threads will have
> >and want it to work with both NPTL and LinuxThreads, you want
> >pthread_attr_setinheritsched (&attr, PTHREAD_*_SCHED);
> >explicitely.
> 
> But since we always set the scheduling class explicitly, should the
> inherited scheduler class make any difference?

Of course.
If you say
pthread_attr_init (&attr);
pthread_attr_setschedpolicy (&attr, SCHED_FIFO);
pthread_attr_setschedparam (&attr, &param);
pthread_create (&th, &attr, fn, arg);
then with LinuxThreads the thread will have FIFO policy while with
NPTL it won't unless the current thread has it.
If you:
pthread_attr_init (&attr);
pthread_attr_setschedpolicy (&attr, SCHED_FIFO);
pthread_attr_setschedparam (&attr, &param);
pthread_attr_setinheritsched (&attr, PTHREAD_INHERIT_SCHED);
pthread_create (&th, &attr, fn, arg);
then the thread will inherit scheduling parameters from current thread,
so unless it has FIFO the the fn thread will not have FIFO policy.
If you:
pthread_attr_init (&attr);
pthread_attr_setschedpolicy (&attr, SCHED_FIFO);
pthread_attr_setschedparam (&attr, &param);
pthread_attr_setinheritsched (&attr, PTHREAD_EXPLICIT_SCHED);
pthread_create (&th, &attr, fn, arg);
then thread will have FIFO policy in both NPTL and LinuxThreads.
For details see
http://www.opengroup.org/onlinepubs/009695399/functions/pthread_attr_getinheritsched.html

The reason why LinuxThreads defaults to PTHREAD_EXPLICIT_SCHED and
NPTL defaults to PTHREAD_INHERIT_SCHED is that those are the cheaper
variants.  LinuxThreads has a manager thread which creates the child
threads, so for INHERIT_SCHED it needs to issue some syscalls to query
scheduling parameters of the thread which called pthread_create.
In addition to this, no matter what inheritsched setting was, if the
desired sched parameters are different from the initial thread, it
needs to issue a system call to set it for the new thread.
NPTL doesn't have a manager thread and a child thread inherits parent
thread's settings without any syscalls anywhere.  For
PTHREAD_EXPLICIT_SCHED, it needs to issue a system call to set scheduling
params to the desired ones.

	Jakub

  reply	other threads:[~2004-06-30 16:59 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-06-30 13:41 2.6.X, NPTL, SCHED_FIFO and JACK Paul Davis
2004-06-30 15:04 ` Ingo Molnar
2004-06-30 15:18   ` Ingo Molnar
2004-06-30 15:26   ` Jakub Jelinek
2004-06-30 16:32     ` Paul Davis
2004-06-30 16:57       ` Jakub Jelinek [this message]
2004-06-30 17:52         ` Paul Davis
2004-06-30 15:05 ` Ingo Molnar
2004-06-30 16:12   ` Paul Davis
2004-06-30 17:07     ` Ulrich Drepper
2004-06-30 17:50       ` Paul Davis
2004-07-01 18:03 ` Matt Mackall
2004-07-01 18:14   ` William Lee Irwin III
2004-07-01 22:45     ` Andrew Morton
2004-07-02  0:45       ` William Lee Irwin III
2004-07-02  1:38         ` Peter Williams
2004-07-02  2:53           ` William Lee Irwin III
2004-07-02  3:03         ` Con Kolivas
2004-07-02  3:05           ` William Lee Irwin III
2004-07-02  3:27     ` Paul Davis
2004-07-02  7:37       ` William Lee Irwin III
2004-07-02 10:40         ` Takashi Iwai
2004-07-06  0:48           ` Peter Williams
2004-07-02 14:42         ` Paul Davis

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20040630165756.GX21264@devserv.devel.redhat.com \
    --to=jakub@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=paul@linuxaudiosystems.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox