trouble with pthread_attr_setschedparam()

View: New views
1 Messages — Rating Filter:   Alert me  

trouble with pthread_attr_setschedparam()

by Phil Pellouchoud :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

I am having trouble getting pthread_attr_setschedparam() to work.  I can
call the function, and I don't get an error back, but when I go to get
the priority, I get back zero, no matter what I set it to.

---- code snippet ----

-- main code.
pthread_attr_init()
pthread_attr_setdetachstate(...PTHREAD_CREATE_JOINABLE)
pthread_attr_getschedparam(sp)
sp.sched_priority = 10;
pthread_attr_setschedparam(sp)
pthread_create(...)
pthread_attr_destroy()

-- thread function
static void* __cdecl ThreadFunc(void* pArg)
    int priority(0);
  pthread_attr_init()
  pthread_attr_getschedparam(sp)

  // right here, sp.sched_priority is always zero!!!

  pthread_attr_destroy()

---- code snippet ----

Also, is there any way to set the priority for a child thread after it
has been created?  Maybe a better way to ask that question is if there
is a way to set a priority for a child thread from a parent thread?
 
-phil

LightInTheBox - Buy quality products at wholesale price!