Bugzilla will be upgraded to version 5.0. The upgrade date is tentatively scheduled for 2 December 2018, pending final testing and feedback.
Bug 125645 - pthread_create does not implement the specified defaults
pthread_create does not implement the specified defaults
Product: Fedora
Classification: Fedora
Component: glibc (Show other bugs)
i386 Linux
medium Severity medium
: ---
: ---
Assigned To: Jakub Jelinek
Brian Brock
Depends On:
  Show dependency treegraph
Reported: 2004-06-09 12:52 EDT by Bob Cook
Modified: 2007-11-30 17:10 EST (History)
3 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2004-06-17 14:04:12 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)

  None (edit)
Description Bob Cook 2004-06-09 12:52:28 EDT
Description of problem:
x=pthread_setschedparam(pthread_self(),SCHED_FIFO,&spt); assert(x==0);
x=pthread_create(&pt,NULL,p,(void *)1234);

according to the man page the
default "schedpolicy" is OTHER
default "schedparam" is 0 and most importantly
default "inheritsched" is EXPLICIT

thus policy of pt should be OTHER and priority 0
instead policy is FIFO and priority is 5

The error induces a context switch on every create which is very
undesirable for master:multiple-worker paradigms

Version-Release number of selected component (if applicable):
2.3.3 stable

How reproducible: Easy

Steps to Reproduce:
#include "pthread.h"
#include <stdio.h>
#include <assert.h>

void *p(void *arg) {
	int i,x; 
	struct sched_param spt={0};
	printf("p policy=%d priority=%d\n",i,spt.sched_priority);
	pthread_exit((void *)8765);
	return NULL;

int main(int argc, char* argv[])
	int i,x=0;
	pthread_t pt;
	void *out;
	struct sched_param spt={0};
x=pthread_setschedparam(pthread_self(),SCHED_FIFO,&spt); assert(x==0);
	x=pthread_create(&pt,NULL,p,(void *)1234);
	return 0;

Actual results:
p policy=0 priority=5

Expected results:
p policy=0 priority=0

Additional info:
Must run as superuser to test.
Comment 1 Jakub Jelinek 2004-06-09 17:38:58 EDT
The man page describes linuxthreads, not NPTL (linuxthreads is the
default pthread library you link against and use its headers, while
at runtime you by default use NPTL).
I looked through the standard and I believe the default is implementation-defined,
but am not 100% sure about this.
Comment 2 Ulrich Drepper 2004-06-17 14:04:12 EDT
There is no default value demanded by the standard.  Inheriting the
value is faster in the implementation.  Programs which wish to not use
the parent thread's value can very easily call pthread_setinheritsched.
Comment 3 Chuck Simmons 2005-11-17 15:15:57 EST
This is still a bug.  The man page states that the default is not to inherit
attributes.  If you don't make the implementation and the man page agree, then
you will continue to get bug reports.

Thanks for wasting my time by not paying attention to perfectly valid bug reports.

Note You need to log in before you can comment on or make changes to this bug.