* thread creation problem
@ 2004-03-04 1:19 Panagiotis Issaris
0 siblings, 0 replies; only message in thread
From: Panagiotis Issaris @ 2004-03-04 1:19 UTC (permalink / raw)
To: linux-kernel
[-- Attachment #1: Type: text/plain, Size: 1311 bytes --]
Hi,
Creating a thread and afterwards changing the priority and policy does
work. But setting the priority and policy when creating a thread doesn't
seem to work any more on 2.6.x/NPTL systems.
After invoking the following:
pthread_attr_init
pthread_attr_setschedpolicy FIFO
pthread_attr_setschedparam 99
pthread_create
The output of pthread_getschedparam within this thread seemed strange to me:
./thr_prio_basic
max priority 99
policy: 0 priority: 0
thread succesfully created
LD_ASSUME_KERNEL=2.4.1 ./thr_prio_basic
max priority 99
policy: 1 priority: 99
thread succesfully created
Is it because of stricter POSIX compliance of NPTL?
Using ltrace and strace didn't really make it clear to me what is going
wrong here.
In the LinuxThread case, I could clearly see the cloning happening and
afterwards the calls to "sched_setscheduler". In the NPTL case, there is
just a call to clone with more params. No calls to change scheduler
params. Does one of the params contain the scheduler options? If not,
how is the kernel supposed to get that information?
I really don't understand why this is happing, any explanation is
greatly appreciated.
With friendly regards,
Takis
PS: I wasn't sure if I should ask this on the glibc mailinglist or this
mailinglist. My apologies if this is off-topic.
[-- Attachment #2: thr_prio_basic.c --]
[-- Type: text/x-c, Size: 1246 bytes --]
#include <string.h>
#include <stdio.h>
#include <pthread.h>
#include <unistd.h>
void* foo( void*p )
{
int policy;
struct sched_param param;
if ( pthread_getschedparam( pthread_self(), &policy, ¶m ) == 0 )
printf( "policy: %d priority: %d\n", policy, param.sched_priority );
}
int main()
{
pthread_t p;
struct sched_param param;
pthread_attr_t attr;
memset( ¶m, 0, sizeof( param ) );
param.sched_priority = sched_get_priority_max( SCHED_FIFO );
#if 0
if ( sched_setscheduler( 0, SCHED_FIFO, ¶m ) == 0 )
printf( "succesfully selected FIFO scheduler\n" );
#endif
printf( "max priority %d\n", param.sched_priority );
if ( pthread_attr_init( &attr ) )
printf( "problem attr init\n" );
if ( pthread_attr_setschedpolicy( &attr, SCHED_FIFO ) )
printf( "problem setschedpolicy\n" );
pthread_attr_setscope( &attr, PTHREAD_SCOPE_SYSTEM );
if ( pthread_attr_setschedparam( &attr, ¶m ) )
printf( "problem setschedparam\n" );
if ( pthread_create( &p, &attr, foo, 0 ) == 0 )
printf( "thread succesfully created\n" );
else
printf( "problem creating thread\n" );
pthread_attr_destroy( &attr );
usleep( 1000000UL );
}
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2004-03-04 1:18 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-03-04 1:19 thread creation problem Panagiotis Issaris
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®