Download presentation
Presentation is loading. Please wait.
Published byHarold Baker Modified over 9 years ago
1
1 RTOS Design Some of the content of this set of slides is taken from the documentation existing on the FreeRTOS website www.freertos.org
2
2 RTOS Design Review states of a process Introduce queues that are used to keep track of processes Introduce the concepts of scheduler and dispatcher
3
3 RTOS Design new terminate d ready running waiting admitted exit scheduler preempt or yield scheduler dispatch I/O or event completion I/O or event wait
4
4 Process Suspension A process can be suspended in two ways: –involuntarily by the RTOS kernel Higher priority process preempts a low priority process –a process can choose to suspend itself Wants to delay (sleep) for a fixed period of time Wait (block) for a resource to become available (e.g. serial port) A blocked or sleeping process is not able to execute, and will not be allocated any processing time.
5
5 Queues Queues are used to keep track of processes. Ready queue –the set of processes that can be run if given access to the CPU. Blocked queue –the set of processes that are waiting on some particular I/O device to become ready or on some event
6
6 Scheduler ready queue blocked queue CPU new process end I/O or event I/O not ready or wait on event scheduler pre-empt or process yield
7
7 Context Switch When the CPU has to execute a new process and the old one has not finished, the system must: –save the state of the old process –then load the saved state for the new process. This is called a context switch. Context switch time is overhead and no useful work is done while the switch takes place. Context switching time depends upon hardware support.
8
8 Scheduler The scheduler is the part of the kernel responsible for deciding which process should be executing at any particular time. The kernel can suspend and later resume a process many times during the process lifetime. The scheduling policy is the algorithm used by the scheduler to decide which process to execute at any point in time.
9
9 Scheduling Decisions The scheduler selects from among the processes in memory that are ready to execute and allocates the CPU to one of them. Scheduling decisions may take place when a process: 1) switches from running to blocked state 2) switches from running to ready state 3) switches from blocked to ready state 4) terminates
10
10 Dispatcher The dispatcher gives control of the CPU to the process selected by the scheduler, this involves: –switching context –switching to user mode –jumping to the proper location in the user program to restart that program It takes time to stop one process and start another. This is called dispatch latency. The dispatcher and scheduler are often referred to as the scheduler.
11
11 Summary Involuntary(by RTOS kernel) and voluntary suspension of process (by itself). Described ready and blocked queues. Reviewed context switch and introduced context switching time Described scheduler, scheduling policy, events for scheduling decisions, dispatcher and dispatch latency.
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.