Changing priority of threads

Santanu Chatterjee <[email protected]>
Newsgroups gmane.linux.real-time.rtlinux.general
Message-ID <[email protected]>
Hi folks,
   I have a small application running, in which I have two real-time
threads. One has a higher priority than the other one. From the high
priority thread I wanna change the priority of the low priority thread
to make it a high priority one, so that the low priority thread will
get the CPU.

  Can anyone please advise me how it could be done? 

What I did:
 
//global definition
pthread_t t1, t2;
struct sched_param p1, p2;

in the init module:
pthread_create(&t1, NULL, f1, 0);
pthread_create(&t2, NULL, f2, 0);

Inside f1(High priority):************************
p1.sched_priority = 5;
pthread_setschedparam(pthread_self,SCHED_FIFO, &p1);

.........
   //change priority of thread t2
    p2.sched_priority = 8;
    pthread_setschedparam(t2, SCHED_FIFO, &p2);

........

Inside f2(low priority):***************************
p2.sched_priority=3;
pthread_setschedparam(pthread_self(), SCHED_FIFO, &p2);
......

I am finding thread exception whenever I am trying to access and set
scheduling information of t2 from t1. Basically what I want are 2
threads( one is higher and one with lower priority) and after some
time, based on a condition I wanna change the low priority thread to
high priority and vice-e-versa. I am new in rtlinux programming.
I couldn't find similar example with rtlinuxfree distribution. I would
highly appreciate any help.

thanks,
santanu
_______________________________________________
Rtl mailing list
[email protected]
http://www2.fsmlabs.com/mailman/listinfo/rtl
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.