![Page 1: [PPT]PowerPoint Presentation - Stanford Universityweb.stanford.edu/class/ee281/presentations/aut2002/... · Web viewThread priorities can be set by the client Threads always run according](https://reader033.vdocuments.net/reader033/viewer/2022051802/5aebf3867f8b9ae5318e5f6c/html5/thumbnails/1.jpg)
Real-Time Operating SystemsReal-Time Operating Systems
Suzanne RivoireNovember 20, 2002
http://www.stanford.edu/~skrufi/rtospres.ppt
![Page 2: [PPT]PowerPoint Presentation - Stanford Universityweb.stanford.edu/class/ee281/presentations/aut2002/... · Web viewThread priorities can be set by the client Threads always run according](https://reader033.vdocuments.net/reader033/viewer/2022051802/5aebf3867f8b9ae5318e5f6c/html5/thumbnails/2.jpg)
Motivating ExampleMotivating Examplevoid main() {do forever{ check keypad; measure temperature; control oven power; decrement timer; update display; wait for clock tick;
}}
![Page 3: [PPT]PowerPoint Presentation - Stanford Universityweb.stanford.edu/class/ee281/presentations/aut2002/... · Web viewThread priorities can be set by the client Threads always run according](https://reader033.vdocuments.net/reader033/viewer/2022051802/5aebf3867f8b9ae5318e5f6c/html5/thumbnails/3.jpg)
Motivating Example - 2Motivating Example - 2
void main() {do forever{ check keypad; measure temperature; check keypad;
control oven; check keypad;
}}
![Page 4: [PPT]PowerPoint Presentation - Stanford Universityweb.stanford.edu/class/ee281/presentations/aut2002/... · Web viewThread priorities can be set by the client Threads always run according](https://reader033.vdocuments.net/reader033/viewer/2022051802/5aebf3867f8b9ae5318e5f6c/html5/thumbnails/4.jpg)
Presentation OutlinePresentation OutlineDefinition of real-timeCharacteristics of RTOS’sExamples
c-OS– AvrX– RTLinux– QNX Neutrino
![Page 5: [PPT]PowerPoint Presentation - Stanford Universityweb.stanford.edu/class/ee281/presentations/aut2002/... · Web viewThread priorities can be set by the client Threads always run according](https://reader033.vdocuments.net/reader033/viewer/2022051802/5aebf3867f8b9ae5318e5f6c/html5/thumbnails/5.jpg)
What What isis real-time? real-time?
Correctness of output depends on timing as well as result
Hard vs. soft real-time
Are Windows and Linux real-time?
![Page 6: [PPT]PowerPoint Presentation - Stanford Universityweb.stanford.edu/class/ee281/presentations/aut2002/... · Web viewThread priorities can be set by the client Threads always run according](https://reader033.vdocuments.net/reader033/viewer/2022051802/5aebf3867f8b9ae5318e5f6c/html5/thumbnails/6.jpg)
In a Hard RTOS…In a Hard RTOS…
Thread priorities can be set by the client
Threads always run according to priority
Kernel must be preemptible or bounded
Interrupts must be bounded
No virtual memory
![Page 7: [PPT]PowerPoint Presentation - Stanford Universityweb.stanford.edu/class/ee281/presentations/aut2002/... · Web viewThread priorities can be set by the client Threads always run according](https://reader033.vdocuments.net/reader033/viewer/2022051802/5aebf3867f8b9ae5318e5f6c/html5/thumbnails/7.jpg)
In a Soft RTOS…In a Soft RTOS…
Like a hard RTOS:– Priority scheduling, with no degradation– Low dispatch latency– Preemptible system calls– No virtual memory (or allow pages to be locked)
Linux: guarantees about relative timing of tasks, no guarantees about syscalls
![Page 8: [PPT]PowerPoint Presentation - Stanford Universityweb.stanford.edu/class/ee281/presentations/aut2002/... · Web viewThread priorities can be set by the client Threads always run according](https://reader033.vdocuments.net/reader033/viewer/2022051802/5aebf3867f8b9ae5318e5f6c/html5/thumbnails/8.jpg)
Basic RTOS ReferencesBasic RTOS References
http://www.dedicated-systems.com/encyc/publications/faq/rtfaq.htm
http://www.steroidmicros.com/mtkernel.html
http://www.qnx.com/developer/articles/dec1200b/
Silberschatz and Galvin, Operating System Concepts.
![Page 9: [PPT]PowerPoint Presentation - Stanford Universityweb.stanford.edu/class/ee281/presentations/aut2002/... · Web viewThread priorities can be set by the client Threads always run according](https://reader033.vdocuments.net/reader033/viewer/2022051802/5aebf3867f8b9ae5318e5f6c/html5/thumbnails/9.jpg)
Example RTOS’sExample RTOS’sMicrium c-OS II http://www.ucos-ii.com/AvrX http://www.barello.net/avrx/RTLinux
http://fsmlabs.com/developers/man_pages/QNX Neutrino http://www.qnx.com/
![Page 10: [PPT]PowerPoint Presentation - Stanford Universityweb.stanford.edu/class/ee281/presentations/aut2002/... · Web viewThread priorities can be set by the client Threads always run according](https://reader033.vdocuments.net/reader033/viewer/2022051802/5aebf3867f8b9ae5318e5f6c/html5/thumbnails/10.jpg)
c-OS IIc-OS II
Features
Sample main() function
Calling OSTaskCreate()
Creating a task
![Page 11: [PPT]PowerPoint Presentation - Stanford Universityweb.stanford.edu/class/ee281/presentations/aut2002/... · Web viewThread priorities can be set by the client Threads always run according](https://reader033.vdocuments.net/reader033/viewer/2022051802/5aebf3867f8b9ae5318e5f6c/html5/thumbnails/11.jpg)
C-OS IIC-OS II Ports to the AVR, ATmega103 Comes with book: Micro-C OS: The Real-Time
Kernel by Jean Labrosse ($52) Features
– Semaphores and mutexes
– Event flags
– Message mailboxes and queues
– Task management (priority settings)
![Page 12: [PPT]PowerPoint Presentation - Stanford Universityweb.stanford.edu/class/ee281/presentations/aut2002/... · Web viewThread priorities can be set by the client Threads always run according](https://reader033.vdocuments.net/reader033/viewer/2022051802/5aebf3867f8b9ae5318e5f6c/html5/thumbnails/12.jpg)
void main (void) { /* Perform Initializations */ ... OSInit(); ... /* Create at least one task by calling OSTaskCreate() */
OSStart();}
C-OS Sample CodeC-OS Sample Code
![Page 13: [PPT]PowerPoint Presentation - Stanford Universityweb.stanford.edu/class/ee281/presentations/aut2002/... · Web viewThread priorities can be set by the client Threads always run according](https://reader033.vdocuments.net/reader033/viewer/2022051802/5aebf3867f8b9ae5318e5f6c/html5/thumbnails/13.jpg)
INT8U OSTaskCreate (void (*task)(void *pd),void *pdata,OS_STK *ptos,INT8U prio);
C-OS Sample CodeC-OS Sample Code
![Page 14: [PPT]PowerPoint Presentation - Stanford Universityweb.stanford.edu/class/ee281/presentations/aut2002/... · Web viewThread priorities can be set by the client Threads always run according](https://reader033.vdocuments.net/reader033/viewer/2022051802/5aebf3867f8b9ae5318e5f6c/html5/thumbnails/14.jpg)
void UserTask (void *pdata) {pdata = pdata;/* User task initialization */while (1) {/* User code goes here *//* You MUST invoke a service provided by µC/OS-II to: *//* ... a) Delay the task for ‘n’ ticks *//* ... b) Wait on a semaphore *//* ... c) Wait for a message from a task or an ISR *//* ... d) Suspend execution of this task */ }}
C-OS Sample CodeC-OS Sample Code
![Page 15: [PPT]PowerPoint Presentation - Stanford Universityweb.stanford.edu/class/ee281/presentations/aut2002/... · Web viewThread priorities can be set by the client Threads always run according](https://reader033.vdocuments.net/reader033/viewer/2022051802/5aebf3867f8b9ae5318e5f6c/html5/thumbnails/15.jpg)
AvrXAvrX
Specs
Internal structures
Sample code: task creation
![Page 16: [PPT]PowerPoint Presentation - Stanford Universityweb.stanford.edu/class/ee281/presentations/aut2002/... · Web viewThread priorities can be set by the client Threads always run according](https://reader033.vdocuments.net/reader033/viewer/2022051802/5aebf3867f8b9ae5318e5f6c/html5/thumbnails/16.jpg)
AvrX SpecsAvrX Specs
Code size: 500-700 words (2x bigger with debug monitor)
16 priority levels
Overhead: 20% of CPU
Version 2.3 for assembly code, 2.6 for C interface
![Page 17: [PPT]PowerPoint Presentation - Stanford Universityweb.stanford.edu/class/ee281/presentations/aut2002/... · Web viewThread priorities can be set by the client Threads always run according](https://reader033.vdocuments.net/reader033/viewer/2022051802/5aebf3867f8b9ae5318e5f6c/html5/thumbnails/17.jpg)
AvrX InternalsAvrX Internals
Routine _Prolog saves state, _Epilog restores it
Task info stored in a PID block and a task control block
Modules for timers, semaphores, etc.
![Page 18: [PPT]PowerPoint Presentation - Stanford Universityweb.stanford.edu/class/ee281/presentations/aut2002/... · Web viewThread priorities can be set by the client Threads always run according](https://reader033.vdocuments.net/reader033/viewer/2022051802/5aebf3867f8b9ae5318e5f6c/html5/thumbnails/18.jpg)
An AvrX TaskAn AvrX Task
AVRX_TASKDEF(myTask, 10, 3){ TimerControlBlock MyTimer; while (1) { AvrXDelay(&MyTimer, 10); // 10ms delay AvrXSetSemaphore(&Timeout); }}
Arguments: task name, additional stack bytes, priority
![Page 19: [PPT]PowerPoint Presentation - Stanford Universityweb.stanford.edu/class/ee281/presentations/aut2002/... · Web viewThread priorities can be set by the client Threads always run according](https://reader033.vdocuments.net/reader033/viewer/2022051802/5aebf3867f8b9ae5318e5f6c/html5/thumbnails/19.jpg)
RTLinuxRTLinux
Additional layer between Linux kernel and hardware
Worst-case dispatch latency on x86: 15 s
![Page 20: [PPT]PowerPoint Presentation - Stanford Universityweb.stanford.edu/class/ee281/presentations/aut2002/... · Web viewThread priorities can be set by the client Threads always run according](https://reader033.vdocuments.net/reader033/viewer/2022051802/5aebf3867f8b9ae5318e5f6c/html5/thumbnails/20.jpg)
RTLinux: Basic IdeaRTLinux: Basic Idea
![Page 21: [PPT]PowerPoint Presentation - Stanford Universityweb.stanford.edu/class/ee281/presentations/aut2002/... · Web viewThread priorities can be set by the client Threads always run according](https://reader033.vdocuments.net/reader033/viewer/2022051802/5aebf3867f8b9ae5318e5f6c/html5/thumbnails/21.jpg)
QNX NeutrinoQNX Neutrino
Powerful hard RTOS
Includes GUI
Memory protection and fault tolerance
![Page 22: [PPT]PowerPoint Presentation - Stanford Universityweb.stanford.edu/class/ee281/presentations/aut2002/... · Web viewThread priorities can be set by the client Threads always run according](https://reader033.vdocuments.net/reader033/viewer/2022051802/5aebf3867f8b9ae5318e5f6c/html5/thumbnails/22.jpg)
SummarySummary
Hard real-time, soft real-time
Characteristics of an RTOS
Example RTOS’s
– Specs
– Internal structure/ideas
– Sample code