Re: Changing priority of threads
Santanu Chatterjee <[email protected]>
| Newsgroups | gmane.linux.real-time.rtlinux.general |
|---|---|
| Message-ID | <[email protected]> |
Hi Raseel, I tried that idea, but I get the same exception. In fact I found that whenever I am trying to access data structure is from one thread to the other thread ( except shared memory ) I find that exception. I have no clue what is the possible reason. If anyone knows any solution or have faced this scenario before, please let me know. thanks, santanu On 1 Dec 2004 04:51:15 -0000, Raseel Bhagat <[email protected]> wrote: > > > Maybe after you reset the thread priority of t2(based on your condition), > when the control goes back to f2, it finds that the thread priority is > supposed to be 3 and not 8. > > I think thats what creating the confusion. > Why don't you set the t2 priority the first time also from f1 and then as > and when the condition changes, the priority is changed to the new priority > of 5 from f itself? > > Thanks, > Raseel > > On Tue, 30 Nov 2004 Santanu Chatterjee wrote : > > > >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 > > > Raseel Bhagat > > _______________________________________________ Rtl mailing list [email protected] http://www2.fsmlabs.com/mailman/listinfo/rtl