Cùng tìm hiểu Real-time operating system (RTOS); components of RTOS;... được trình bày cụ thể trong Bài giảng Real-time Systems: Week 2 - Real-time Operating System (RTOS).
Trang 2 Real-time operating system (RTOS)
Trang 3NLT, SoICT, 2014
Brief history
60’s-70’s: UNIX for multi-user computer systems
80’s: Windows for personal computing
environments
Later in 80’s ~:
Embedded system changes human’s life, dominates
CPU market
demand for RTOS
UNIX, Windows: General purpose OS (GPOS)
FreeRTOS, VxWork, QNX: RTOS
RTOSes are usually not known to consumers! Consumers can use
electronic devices without knowing what’s inside And that’s one big
point of embedded system.
Trang 4Comparing RTOS and GPOS
Similarity between RTOS & GPOS
Multitasking
Software and Hardware resource management
Provision of underlying OS services to applications
Abstracting the hardware from the software applications
Difference between RTOS and GPOS
Better reliability
Scalability
Faster performance (in real-time contexts)
Reduced memory requirements
Support for diskless embedded systems
Trang 5NLT, SoICT, 2014
Definition of RTOS
Program that schedules execution in a timely manner, manages
system resources, and provides a consistent foundation for
developing embedded application code
RTOS components
Trang 6RTOS kernel components
Trang 7NLT, SoICT, 2014
Definition of RTOS
RTOS kernel components:
Scheduler: provides a set of scheduling algorithms to
determine which and when task executes.
- Two most used approaches: preemptive, round robin
Objects: special kernel constructs to help developers
create embedded applications
- Ex: tasks, semaphores, message queues
Services: kernel operations on objects
- Ex: timing, interrupt handling, & resource management
Trang 9 Task: a schedulable entity
Independent thread of execution that contains a sequence of
independently schedulable instructions
This course focuses on tasks
Task vs thread?
Trang 10 The kernel should ensure that all tasks meets their deadlines.
The tasks follows the kernel’s scheduling algorithms, while
interrupt service routines are triggered to run because of HW
interrupts and their established priorities
Higher CPU performance is required as the number of tasks
increases
- More frequent context switching
Trang 11NLT, SoICT, 2014
Context switching(1)
Each task has its own context
eg: states of CPU registers
A context switch occurs when a scheduler switches from one task to another
Frequent context switching causes unnecessary
performance overhead
Trang 12Context switching(2)
Trang 13NLT, SoICT, 2014
The dispatcher(1)
The dispatcher:
A part of scheduler that performs context switching
and changes the flow of execution.
At any time an RTOS is running, the flow of
execution(flow of control), is passing through one of three areas:
- through an application task,
- through an ISR,
- through the kernel
Scheduler decides when and how to execute context
switching
Trang 14The task that gets to run at any point
is the task with the highest priority
Priority-based round robin:
Combine advantages of priority based
and round robin algorithm
Trang 15NLT, SoICT, 2014
Scheduler vs dispatcher
Ex: which thread will the code below be scheduled on?
Will context switching happen?
int threadProc(int param){
tbMsg.Text = "Parsing done!";
}});
}
Trang 16Scheduler vs dispatcher
Dispatcher
Low level mechanism
Responsibility: context switching
Scheduler
High level policy
Responsibility: deciding which task to run
Trang 17 Token-like objects for synchronization or mutual exclusion
Incremented or decremented by tasks
Message queues
Buffer-like data structures for synchronization, mutual exclusion,
& data exchange between tasks
Trang 18 Others are accessible via API
refer to OS’s document
Trang 20 Embedded system might need to operate for long
periods without human intervention Eg: network devices
Different degrees of reliability may be required
A digital solar-powered calculator reset: acceptable
A telecom switch reset: unacceptable, costly to recover
The RTOSes in these applications require different degrees of reliability
Trang 21NLT, SoICT, 2014
Predictability
Meeting time requirements is key for proper operation
The RTOS needs to be predictable (at least to a certain degree)
Deterministic operation: RTOSes with predictable
behavior, in which the completion of operating system
calls occurs within known timeframes.
Trang 22 Fast enough to fulfill timing requirements
The more deadlines to be met the faster the system's CPU must be
Both hardware and software contribute to system
performance
Trang 23NLT, SoICT, 2014
Compactness
Constraints of embedded systems:
Application design constraints
Cost constraints
Design requirements
Limit system memory
Limits the size of the application
Cost constraints:
Limit power consumption
Avoid expensive hardware
RTOS must me small and efficient!
Trang 24 RTOSes can be used in a wide variety of embedded
systems
Scale up or down to meet application-specific requirements
Scale up: Adding additional hardware and its corresponding
software modules, eg disk drive, sensor…
Scale down: removing unnecessary hardware drivers and
software modules