This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

rtx51 timeslice

hi every one.

i am new to rtx51. i have one doubt as follows:

if i have a round robin time slice of 5msec. and my code is:

job1 () _task_ 1 {
while (1) {
counter1++;
os_wait (K_TMO, 5, 0);
} }

job2 () _task_ 2 {
while (1) {
counter2++;
os_wait (K_TMO, 3, 0);
} }

if the control is in job1.so, counter1 gets incremented and let us assume the time taken for the increment instruction is 2msec. After that because of os_wait it jumps to task2.

My question is, whether the control goes to task2 after 2msec or 5 msec(completion of timeslice)?

Thanks in advance

Parents
  • You need to read a bit deeper into the RTX51 manual. You have two cross purposes. But to answer your question, Task 1 will suspend as soon as it hits the os_wait statement. The 5 in the pramater list is in RTX 'ticks'. If you have your RTX ticks are set at 5 millisec, then your wait is 25 millisec and then Task 1 will 'go ready'. The same for task 2 but for a different wait time. Notice the term 'go ready'. Task 1 is just marked ready in the task queue. If any other task is active, task 1 will resume only when it is the next ready device in the queue.
    You do not specify the clock rate or device type but assuming a simple 8051 at 12 MHz and 12 clock cycles, you would spend much more time in switching overhead than running your code. With the stated 8051, a 10 millisec tick should be the smallest than you select.
    Also, if you are planning to use co-operative task switching (os_waits) then you should disable round robin time sliceing.
    All of this and much more is in the RTX documentation.
    Bradford

Reply
  • You need to read a bit deeper into the RTX51 manual. You have two cross purposes. But to answer your question, Task 1 will suspend as soon as it hits the os_wait statement. The 5 in the pramater list is in RTX 'ticks'. If you have your RTX ticks are set at 5 millisec, then your wait is 25 millisec and then Task 1 will 'go ready'. The same for task 2 but for a different wait time. Notice the term 'go ready'. Task 1 is just marked ready in the task queue. If any other task is active, task 1 will resume only when it is the next ready device in the queue.
    You do not specify the clock rate or device type but assuming a simple 8051 at 12 MHz and 12 clock cycles, you would spend much more time in switching overhead than running your code. With the stated 8051, a 10 millisec tick should be the smallest than you select.
    Also, if you are planning to use co-operative task switching (os_waits) then you should disable round robin time sliceing.
    All of this and much more is in the RTX documentation.
    Bradford

Children