Search code examples
multithreadingoperating-systemfreertosrtosrtx

What is 1 thread execution time (quantum) if number of concurrent threads is 10 and SysTick time is 10mSec?


I am currently working with RTOS, their I have Time Tick Value = 10 mSec and Number of concurrent running tasks = 10.

Now my question is, What should be my Single Thread Time (quantum)?

I think, Single Thread Time = Time Tick Value / Number of concurrent running tasks but I am not sure. Please correct me if I am making any mistake here.

Also what are the factors that were responsible for change-in Single Thread Time?

TERMINOLOGIES:

Time Tick Value: The available CPU time is divided into time slices and the RTX kernel assigns a time slice to each task (default time slice is set to 10 ms).

Single Thread Time is the time slice taken by one thread in round robbin scheduling if their are total 10 tasks (threads).

Number of concurrent running tasks always remain constant. It will not cover thread waiting time.

What I wanna know is, whether 10 mSec time slice given to single thread or it gets divide again into 10 parts for 10 concurrent running threads (Consider I am using round robbin scheduling).


Solution

  • For a round robin scheduler using 10 ms time slices, if there is one CPU and always 10 tasks; then there will always be one task actually using the CPU and 9 tasks waiting to use the CPU. In this case the scheduler gives a task 10 ms of CPU time, then preempts and does a task switch to the next task and gives it 10 ms of time, and so on; so each task would get 10 ms of CPU time every 100 ms.

    What I wanna know is, whether 10 mSec time slice given to single thread or it gets divide again into 10 parts for 10 concurrent running threads (Consider I am using round robbin scheduling).

    For round robin, the time slice length is the time any task will be given - the 10 ms slices won't be sliced up into smaller slices (otherwise it'd be a round robin with 1 ms time slices, or it wouldn't be round robin - e.g. would become "variable time slice").