![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Rules & FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| UNIX for Advanced & Expert Users Advanced UNIX and Linux questions go here. Expert-to-Expert. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Get real value from real-time systems | iBot | Complex Event Processing RSS News | 0 | 01-13-2008 10:10 PM |
| capturing real time | wisher115 | UNIX for Dummies Questions & Answers | 2 | 09-22-2006 06:26 PM |
| EPOCH to real time? | TheEngineer | UNIX for Advanced & Expert Users | 5 | 07-18-2006 05:30 AM |
| log users real time | chanfle | UNIX for Dummies Questions & Answers | 3 | 03-22-2006 01:31 PM |
| multiplex programming in real-time OS. | bsderss | UNIX for Advanced & Expert Users | 0 | 08-10-2005 01:24 AM |
|
|
LinkBack | Thread Tools | Display Modes |
|
|||
|
Schedule Real time threads
I want to set the priority and the scheduler as SCHED_FIFO for two threads . I want to see that the thread with high priority will run forever .
A simple code is given below . But both the threads are being scheduled . Why this is happening ? I am executing the code as root. I expect to see only the string P1 since the function doit1 is being executed by the thread with priority 35. But the string P2 is also being printed whose thread priority is 32. #include<stdio.h> #include<pthread.h> #include<sys/types.h> void *doit1(void *); void *doit2(void *); pthread_attr_t tattr1; pthread_attr_t tattr2; struct sched_param param1; int main() { int i,a; pthread_t th1,th2; pthread_attr_init(&tattr1); pthread_attr_init(&tattr2); pthread_attr_setschedpolicy(&tattr1 , SCHED_FIFO); pthread_attr_setschedpolicy(&tattr2 , SCHED_FIFO); param1.sched_priority=35; pthread_attr_setschedparam(&tattr1 , ¶m1); param1.sched_priority=32; pthread_attr_setschedparam(&tattr2 , ¶m1); pthread_create(&th1,&tattr1,doit1,NULL); pthread_create(&th2,&tattr2,doit2,NULL); pthread_join(th1,NULL); pthread_join(th2,NULL); } void * doit1(void *ptr) { while (1) write(1,"P1",2); return NULL; } void * doit2(void *ptr) { while (1) write(1,"P2", 2); return NULL; } 54,1 68% |
|||
| Google UNIX.COM |
| Forum Sponsor | ||
|
|