??? 08/31/04 18:53 Read: times Msg Score: 0 -1 Off-Topic +1 Underrated |
#76694 - Calculating task priority |
Something I've just added to my TinyOS is the ability to make tasks run with different priorities. It seemed like a logical next step in its maturity. To understand how it works, first assume four tasks T1, T2, T3, T4 that each can run for PX*256 CPU cycles, where PX is P1, P2, P3, P4, each a number between 0 and 255. A task with 255 will get 255*256 CPU cycles.
Next, let's suppose I want tasks 1,2,3 to run at equal and highest priority, 255. I want task 4 to get 15% of the CPU power, leaving 1,2,3 to each get approx 28%. To calculate the number of 256-cycle blocks that task 4 will get, I start out be making the ratio P4 / (P1 + P2 + P3 + P4) = 0.15 We know that P1 = P2 = P3 = 255, so it simplifies to: P4 / (3*255 + P4) = 0.15 then, P4 / (765 + P4) = 0.15 next, P4 = 0.15(765 + P4) or, P4 = 114.75 + 0.15P4 which is, (1-0.15)P4 = 114.75 finally, P4 = 114.75 / .85 = 135 So, for Task 4 to get 135 cycle blocks of 256, I would assign the value (255-135)=120 to its task_priority value. Checking: 120 / (255 + 255 + 255 + 135) is indeed 0.15 Check out v0.4 of my TinyOS to see how it gets used |
Topic | Author | Date |
Calculating task priority | 01/01/70 00:00 | |
Another welcome feature... | 01/01/70 00:00 | |
Excellent idea![]() | 01/01/70 00:00 | |
RE: Calculating task priority | 01/01/70 00:00 | |
RE: Calculating task priority | 01/01/70 00:00 |