View topic - what' wrong with the code?

what' wrong with the code?

anything that doesn't fit to other groups.

what' wrong with the code?

Postby xuyong » Mon Jul 14, 2003 12:45 am

I have 2 threads,I want to thread2 running as the thread2 is idle,so I think
I should reduce the priority level of thread2 compared with thread1,below is my code to achive it,but after doing that the priority level of thread1 and thread2 is still same.
void*thread1()
{
pthread_attr_t attr;
int policy=SCHED_FIFO;
struct sched_param param;
pthread_attr_init( &attr );
pthread_getschedparam(pthread_self(),&policy,¶m);
param.sched_priority --;
pthread_attr_setschedparam(&attr, ¶m);
pthread_create (NULL, &attr, thread2, NULL);
}
xuyong
Senior Member
 
Posts: 431
Joined: Sun Mar 02, 2003 7:52 am

Postby cdm » Mon Jul 14, 2003 4:29 am

You need to also change the inherit vs. explicit sched value...
pthread_attr_setinheritsched()

Take a look at that call.
cdm
QNX Master
 
Posts: 789
Joined: Fri Jul 05, 2002 9:38 am


Return to General Programming

Who is online

Users browsing this forum: No registered users and 3 guests

cron