Subj : Help: pthread priority in Linux 2.4 Kernel To : comp.programming.threads From : forSale Date : Tue Aug 02 2005 12:08 pm Hi, I am running redHat 9 with all the starndard kernel config that comes with redHat 9. I am trying to create threads with multiple priorities. However although it looks very simple, I dont see the priority of the thread not taking any affect. I am compling the code under "root". I think there is something missing in the kernel config or gcc flag which affects my priority of the thread. Following is my code #include #include void * testThread(void *arg) { while (1)) printf ("Thread--- %s \n", (unsigned char *) arg); } int main () { pthread_attr_t attr; pthread_t thread1, thread2; struct ched_param param; pthread_attr_init(&attr); param.sched_priority =20; pthread_attr_setschedpolicy(&attr, SCHED_FIFO); pthread_attr_setchedparam(&attr, ¶m) pthread_create(&thread1, &attr,testThread, "Thread1"); param.sched_priority =22; pthread_create(&thread2,&attr,testThread, "Thread2"); pthread_join ( thread1, NULL) } To compile the code I do the following linux2.4.22> gcc testThead.c -o testThread -lpthread linux2.4.22> ./testThead Thread ---Thread 1 Thread ---Thread 1 Thread ---Thread 1 Thread ---Thread 1 Thread ---Thread 1 Thread ---Thread 1 Thread ---Thread 1 Thread ---Thread 2 Thread ---Thread 2 Thread ---Thread 2 Thread ---Thread 2 Thread ---Thread 2 Thread ---Thread 2 Thread ---Thread 1 Thread ---Thread 1 Thread ---Thread 1 Thread ---Thread 1 ...... Now Since thread 2 has higher priority than thread1. Thread1 should never get executed once thread2 start to run. Why is the thread1 getting executing again. Can someone help.. What am I doing wrong ????? Thanks in advance Ottawa .