Documente Academic
Documente Profesional
Documente Cultură
Microprocesors, Advanced
The RTOS
The kernel the multitasker
The kernel handles tasking It also has resources to pass data between tasks safely, and to synchronize tasking.
An RTOS also has resources like communications, a GUI, a file system, and debugging tools.
Polled Loop
Wait for something
Do something
Handle Interrupt
Handle screen
Signal RTOS
Handle TCP/IP
Process data
An Infusion Pump
Task Creation
void main (void) { OSInit();
/* Kernel initialization */
*/
Task state
Other task data
Task States
Scheduling
Preemption
The suspension of one task and start of another
Context switching
The process of switching from one task to another
Round robin
The giving of equal time to all same-priority tasks
Round-Robin Scheduling
Priorities
Scheduling Points
When a task decides to wait for time to expire When a task sends a message or a signal to another task When an ISR sends a message or a signal to a task When a kernel object is deleted When the priority of a task is changed Other places
I/O Perils
HHio wTdhyere
The Mutex
Semaphores
AtoD_Read (uint16 *result) { start ADC conversion wait for semaphore Read A/D return result }
Message Queues
Rx ISR
Message queue
// Task A if angle> 90 swap modes void a (void){ int raw; float angle; float scale=2*pi; raw=inport(encoder); angle=(float)raw * scale; if(angle>90)swap_mode; }
0013DA 0013DF 0013E2 0013E7 0013EA 0013EF 0013F2 0013F7 0013FC 0013FF
9A 83 9A FF 9A 83 9A 9A 83 9A
00 C4 00 76 00 C4 00 00 C4 00
00 04 00 FC 00 02 00 00 10 00
CALL ADD CALL PUSH CALL ADD CALL CALL ADD CALL
ddload SP,4 dpush WORD PTR [BP-4] dicvt SP,2 dpush drmul SP,16 dpush
k=(l1>l2); 000E8A 000E8D 000E90 000E93 000E95 000E97 000E9A 000E9C 000E9F 000EA1 000EA3 000EA6 8B 8B 3B 7F 7C 3B 76 B8 EB 2B 89 FF 56 46 56 07 0A 46 05 01 02 C0 46 46 CA C8 D6 MOV MOV CMP JG JL CMP JBE L42 MOV JMP L40 SUB L41 MOV INC DX,[BP-54] AX,[BP-56] DX,[BP-42] SHORT L42 SHORT L40 AX,[BP-44] SHORT L40 AX,1 L41 AX,AX BP-10],AX [BP-2]
D4
00
F6 FE
Software Selection
CPU/Language/Tool compatibility Pricing model Source or object? Size and performance Debugging tools Services, drivers Other software components
Questions?