160 likes | 203 Views
Engineering Open House. Need students to demo their players on Friday 3-4 Saturday 10-2. Embedded Software Architectures. No Operating System Round robin: sequential polling for events Round robin w/ interrupts Function Queue Scheduling Real Time Operating System.
E N D
Engineering Open House • Need students to demo their players on • Friday 3-4 • Saturday 10-2.
Embedded Software Architectures • No Operating System • Round robin: sequential polling for events • Round robin w/ interrupts • Function Queue Scheduling • Real Time Operating System
What are the time critical functions?Flipping channels, change tones at end of timeslice What are the housekeeping functions? TNE count down and stream processing (TNE, Tones) Do these have hard time constraints too? Yes, one time slice (18ms)…good enough? Not necessarily…serial is undefined! Maestro in RR+INT volatile bit fEndOfSlice, fSerial; void isr(void) interrupt … { process_tones(); if (!--sliceCount) { changeTones(); sliceCount = SliceSize fEndOfSlice = TRUE; } } void serial(void) interrupt …{ timeCritical(); fSerial = TRUE; } main () { if (fSerial) {process_serial_data(); fSerial = FALSE;} if (fEndOfSlice) { if (--TNE==0) process_next_event(); fEndOfSlice = FALSE; } }
Task Diagram Worst case analysis: character comes one cycle before TF0 Worst case latency: Sum of max of all task functions. Advantage over RR: Critical Stuff happens in ISR time slice start time slice end serial_isr isr serial housekeeping main deadline timer0 overflow occurs (TF0) char arrives Can we do better?
What isthe advantage of this? Programmer can set priority for task functions. Worst case latency for priority n task function? Sum of max execution time for all task functions of priority > n + max current task With only two tasks, it is the same as RR+INT. And it does not allow any non-deterministic tasks. Function Queue void isr(void) interrupt … { process_tones(); if (!--sliceCount) { changeTones(); sliceCount = SliceSize; enq(process_time_slice); } } void serial(void) interrupt …{ timeCritical(); enq(process_serial_data); } void main(void) { while (1) if (f = deq()) { *f()); } You get a scheduling opportunity every time a task completes.
Task Diagram Worst case analysis: Its actually different…serial has to get started Worst case latency: Sum of max of all task functionsAdvantage: Can support priorities, but still at mercy of slowest task. time slice start time slice end serial_isr isr serial housekeeping main not worst case deadline timer0 overflow occurs (TF0) char arrives Can we do better?
Comparison Non OS Architectures • See Chapter 5, table 5.1 Simon
Real Time Operating Systems • What is the basic thing we want the OS to do to help us improve worst case latency? Enable multithreading • How? Define an OS time-slice (tick) at which highest priority ‘runnable’ task is continued. Priority function determines response behavior. • Simplest Scheduling algorithm: each task gets at most 1 tick at a time to run. Round Robin Scheduling. Worst case task latency = #tasks*tick. Worst case run time = ticks/task * #tasks • Some properties of such system: liveness, safety, fairness, latency, overhead. • Other niceties: Device Drivers, Synchronization, Data Sharing (messages, queues, etc.), Memory Management
Programmers View • Advantages: • Deterministic response time even w/ non deterministic tasks lengths. • Incremental development • Resources: • Task switching overhead • Memory overhead • Use of system timer • Degrades best case response time. void tone_isr(void) interrupt … { process_tones(); if (!--sliceCount) { changeTones(); sliceCount = SliceSize isr_send_signal(MUSIC); } } void serial_isr(void) interrupt …{ timeCritical(); os_send_signal(SERIAL); } void play(void) _task_ MUSIC { os_create(SERIAL); while (1) {os_wait(); process_next_event();} } void serial(void) _task_ SERIAL { while (1) {os_wait(); process_serial_data();} // os_create(MUSIC)? } Tasks are threads
Task Diagram os time slice os time slice os time slice os time slice music time slice start music time slice end serial_isr music_isr serial music OS Music task is never more than one OS time slice away Char arrives
Another Solution • Multiprocessor: Dedicate one processor to each (or a few) tasks. • Still need synchronization and communication. • Our Orchestra network could be an example of a multiprocessor system
Design Meeting • What’s next? • Streaming
Orchestra Functions • Time of day • Get data from net, send to player or to pilot • Send music to net • Get music from net • Play music • Task to play music from net • Task to create/delete other tasks (master)
Basic Architecture of an RT OS • Task Table • Process state, signal flag, time_out counter, context • System Interrupt Service Routine (timer) • System Calls (Code, time)
Embedded Software • Software States v. Finite State Machines • Hierarchical State • Thread/Process Communication • Critical Sections • Synchronization • Messaging and Signaling