120 likes | 272 Views
Advanced Embedded Systems Design. Lecture 7 Rate Monotonic Analysis, Hybrid scheduling BAE 5030 - 003 Fall 2004 Instructor: Marvin Stone Biosystems and Agricultural Engineering Oklahoma State University. Goals for Class Today. Questions over reading (Chapter 17, Hybrid Scheduler)
E N D
Advanced Embedded Systems Design Lecture 7 Rate Monotonic Analysis, Hybrid scheduling BAE 5030 - 003 Fall 2004 Instructor: Marvin Stone Biosystems and Agricultural Engineering Oklahoma State University
Goals for Class Today • Questions over reading (Chapter 17, Hybrid Scheduler) • Rate Monotonic Analysis (Aswin Ramachandran) • Hybrid Scheduler • Set assignment
Hybrid Scheduler - Pont • Objective • Provide centralized scheduling/dispatching • Provide a time triggered task scheduling function • Provide for a support for a single pre-emptive task • Determinancy • User may assure the configuration is determinant • Simple inter-task communications • Limitations • A priori static task scheduling by user • Single preemptive task with effect determined by user • Latency set by scheduler tick
Timing issues • How often could the serial ISR be called? • Select a baud rate – 9600 baud • Character rate for back to back chars ~ 960 char/sec • ~1 ms per char • Serial ISR might be called at ~1ms period at max char rate • What time triggered period for line parser? • Set min line length – 3 char • Max line rate = 1/(4 chars * 1ms) = 250 chars/s • Period should be at least 4 ms • Can Line Parser execute along with Serial ISR and not miss characters? • 4*ISR time + Line Parser time for 4 chars including printing
Ring Buffer - methods • Need • Initialize buffer • Read from • Write to • Issues • Must distinguish: • Empty • Full
Ring Buffer Implementation (Untested) • Serial ISR char RXbuf[RXBUFSIZ]; // head is the index of the front element in the buffer int RXhead, RXtail; // tail is the index of the array element at which the next // element will be inserted void serial_ISR(void) interrupt SERIAL_INTERRUPT using 1 { if (RXhead != RXtail) // Check for buffer empty { if (++RXtail >= RXBUFSIZ) RXtail = 0; // Increment tail pointer, fix end of ring condition if (RXhead != RXtail) // Ring buffer filled { RXbuf[RXtail] = SBUF; // read UART char into ring buffer } else { RXtail--; // don't accept more characters // Set and error flag to allow this error to be found } } // clear serial interrupt ? }
Ring Buffer Implementation (Untested) • Read Ring buffer char Get_from_Ring_buf( void ) // Read characters from the ring buffer { char temp_char; if (RXhead != RXtail) //Check for buffer empty { temp_char = RXbuf[RXhead]; // Get a character from the ring if (--RXhead <= 0) RXhead = RXBUFSIZ; // Decrement the head, fix the end of ring condition return(temp_char); } else return(0); // Buffer empty, this return condition is the same as a null character! }
Assignment • Complete last weeks homework • Read Pont, Chapter 18 • Tutorial – 30 min • Review State machine shortcuts by Michael Kreiman , Embedded Systems Journal