Download presentation
Presentation is loading. Please wait.
Published byValerie Matthews Modified over 8 years ago
1
Chapter 3 RTOS Concepts And Definitions Department of Computer Science Hsu Hao Chen Professor Hsung-Pin Chang
2
Outline(1/2) Priorities Ready threads and suspended threads Preemptive, priority-based scheduling Round-Robin scheduling Kernel 、 RTOS Context Switch
3
Outline(2/2) Interrupt handling 、 Thread starvation Priority inversion Priority inheritance Preemption-threshold
4
Priorities(1/2) Most real-time systems use a priority system as a means of establishing the relative importance of threads. Priorities include two classes Static priority Dynamic priority ThreadX provides priority values from 0 to 31,the value 0 represents the highest priority
5
Priorities(2/2)
6
Ready threads and suspended threads(1/3) ThreadX maintains to manage threads two classes Suspended Threads List Occur Wait for an unavailable resource Removed It is placed on the Ready Thread List It is terminated
7
Ready threads and suspended threads(2/3)
8
Ready threads and suspended threads(3/3) Ready Threads List Occur Thread is ready for execution Remove When ThreadX schedules a thread for execution If all the threads on the list have equal priority,ThreadX selects the thread that has been waiting the longest.
9
Preemptive, priority-based scheduling A higher priority thread can interrupt and suspend a currently executing thread that has a lower priority
10
Round-Robin scheduling Provide processor sharing in the case in which multiple threads have the same priority Two primary ways are supported by ThreadX : Round-robin processing and cooperative multithreading
11
Round-Robin scheduling
12
Kernel 、 RTOS A kernel is minimal implementation of an RTOS Consists of at least a scheduler and a context switch handler Full-blown operating systems RTOS is dedicated to the control of hardware and must operate within specified time contraints
13
Context Switch Context is the current execution state of a thread Consists of such items as the program counter,register and stack pointer Context switch refers to the saving or restoring a different thread ’ s When a thread ’ s context is restored then the thread resumes execution at the stopping point
14
Interrupt handling 、 Thread starvation Interrupt handling Interrupt vector Interrupt service routine (ISR) Thread starvation Priority-based scheduling Solution would be to gradually raise the priority of starved
15
Priority inversion
16
Preemption-threshold Disabling preemption Threads with priorities higher than 15 will be permitted Even though priorities 15 through 19 are higher than thread ’ s priority of 20,threads with those priorities will not be allowed to preempt this thread
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.