RE: pthread_attr_setschedpolicy(), pthread_attr_setschedparam(), pthread_attr_setinheritsched() not working with NPTL

"Selbak, Rolla N" <[email protected]>
Newsgroups gmane.comp.lib.phil
Message-ID <[email protected]>
Hey there,

the reason why this capability is disabled is because there is not enough underlying futex code support in the kernel _yet_...


Rolla


* my views are not necessarily my employer's *

-----Original Message-----
From: Takashi Oe [mailto:[email protected]]
Sent: Monday, July 28, 2003 5:33 AM
To: [email protected]
Subject: pthread_attr_setschedpolicy(), pthread_attr_setschedparam(),
pthread_attr_setinheritsched() not working with NPTL


Hi,

The following code produces the output "priority = 0, policy = 0", while
it seems the output of "priority = 10, policy = 1" be more appropriate:

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <pthread.h>

static void *thread(void *unused)
{
        struct sched_param p;
        int policy;

        pthread_getschedparam(pthread_self(), &policy, &p);

        fprintf(stderr, "priority = %d, policy = %d\n", p.sched_priority,
		policy);

        pthread_exit("DONE");
}

int main(void)
{
        pthread_attr_t attr;
        struct sched_param p;
        pthread_t tid;

        pthread_attr_init(&attr);
        pthread_attr_setschedpolicy(&attr, SCHED_FIFO);
        p.sched_priority = 10;
        pthread_attr_setschedparam(&attr, &p);
        pthread_attr_setinheritsched(&attr, PTHREAD_EXPLICIT_SCHED);

        pthread_create(&tid, &attr, thread, NULL);
        pthread_join(tid, NULL);

        return 0;
}

After some searching, I found that changing
nptl/pthread_create.c::__pthread_create_2_1()'s following line:

  if (0 && attr != NULL)

to

  if (attr != NULL)

makes the sample code work as expected.

It seems setting the scheduling portion of user attr were intentionally
disabled in nptl.  Does it still need to be disabled?  Could someone tell
me what the issues are?


Takashi Oe


-- 
Phil-list mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/phil-list
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.