mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Malcolm Rowe <malcolm-linux@farside.org.uk>
To: linux-kernel@vger.kernel.org
Subject: Can't change priority via sys_sched_setscheduler()?
Date: Fri, 28 Apr 2006 12:23:31 +0100	[thread overview]
Message-ID: <20060428112331.GA9702@lorenz.farside.org.uk> (raw)

Sorry, this is probably a silly question, but what's the correct way to
adjust (reduce, in my case) the priority of a SCHED_NORMAL/SCHED_OTHER
pthread?

glibc translates calls to pthread_setschedprio and pthread_setschedparam
into sys_sched_setparam and sys_sched_setscheduler respectively, which
both end up at sched_setscheduler(), which does:

        /*
         * Valid priorities for SCHED_FIFO and SCHED_RR are
         * 1..MAX_USER_RT_PRIO-1, valid priority for SCHED_NORMAL and
         * SCHED_BATCH is 0.
         */
        if (param->sched_priority < 0 ||
            (p->mm && param->sched_priority > MAX_USER_RT_PRIO-1) ||
            (!p->mm && param->sched_priority > MAX_RT_PRIO-1))
                return -EINVAL;
        if ((policy == SCHED_NORMAL || policy == SCHED_BATCH)
                                        != (param->sched_priority == 0))
                return -EINVAL;

So calls to (for example)
  struct sched_param sp = {9};
  pthread_setschedparam(scthread, SCHED_OTHER, &sp);

Will fail with EINVAL.  Yet calls to setpriority(PRIO_PROCESS, 0, 9)
within the thread will work as expected.

I suspect I'm missing something - what is it?

Thanks,
Malcolm
(please cc: me, I'm not subscribed)

                 reply	other threads:[~2006-04-28 11:23 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20060428112331.GA9702@lorenz.farside.org.uk \
    --to=malcolm-linux@farside.org.uk \
    --cc=linux-kernel@vger.kernel.org \
    /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

Powered by JetHome