Bug 7013 - Policies permitted by pthread_attr_setschedpolicy() inconsistent with pthread_setschedparam()
Summary: Policies permitted by pthread_attr_setschedpolicy() inconsistent with pthread...
Status: NEW
Alias: None
Product: glibc
Classification: Unclassified
Component: nptl (show other bugs)
Version: 2.8
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
: 10828 (view as bug list)
Depends on:
Blocks:
 
Reported: 2008-11-06 16:18 UTC by Michael Kerrisk
Modified: 2014-07-01 05:35 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:
fweimer: security-


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Michael Kerrisk 2008-11-06 16:18:30 UTC
In nptl/pthread_attr_setschedpolicy.c there are the lines

  /* Catch invalid values.  */
  if (policy != SCHED_OTHER && policy != SCHED_FIFO && policy != SCHED_RR)
    return EINVAL;

In pthread_setschedparam(), there is not an analogous check.

This means that one can set, for example, a SCHED_BATCH policy with 
pthread_setschedparam(), but one can't initialize a thread attributes object
that can be used to create a thread running under the SCHED_BATCH policy.  

This seems rather inconsistent.  Either pthread_setschedparam() should place the
same restriction as pthread_attr_setschedpolicy(), or the restriction should be
removed from pthread_attr_setschedpolicy().  Given that the POSIX.1
specification of pthread_attr_setschedpolicy() says:

    The  supported  values  of  policy  shall  include  SCHED_FIFO,
    SCHED_RR, and SCHED_OTHER, which are defined in  the  <sched.h>
    header.

removing the restriction from pthread_attr_setschedpolicy() seems the more
reasonable course, so that applications can take advantage of the additional
scheduling policies provided by Linux.
Comment 1 Petr Baudis 2010-06-01 03:08:53 UTC
*** Bug 10828 has been marked as a duplicate of this bug. ***