Saturday, May 23, 2015

Learning Basic OS Preemption

I was curious about how OS preemption is implemented.   I think the best way is to learn from the simplest OS.

I found FreeRTOS to be a good real OS that can help me learn those implementation detail.

http://en.wikipedia.org/wiki/Real-time_operating_system
http://en.wikipedia.org/wiki/FreeRTOS


It also help that FreeRTOS is documented as part of "The Architecture of Open Source Applications" Book II.  

Source: http://www.aosabook.org/en/freertos.html

"...The heartbeat of a FreeRTOS system is called the system tick. FreeRTOS configures the system to generate a periodic tick interrupt. The user can configure the tick interrupt frequency, which is typically in the millisecond range. Every time the tick interrupt fires, the vTaskSwitchContext() function is called. vTaskSwitchContext() selects the highest-priority ready task and puts it in the pxCurrentTCB variable like this..."

See Also.

...
CFS (which is default scheduler for processes) has no fixed timeslice, it is calculated at runtime depending of targeted latency (sysctl_sched_latency) and number of running processes. Timeslice could never be less than minimum granularity (sysctl_sched_min_granularity).
Timeslice will be always between sysctl_sched_min_granularity and sysctl_sched_latency, which are defaults to 0.75 ms and 6 ms respectively and defined in kernel/sched/fair.c.
But actual timeslice isn't exported to user-space.
...
...
























































No comments:

Post a Comment