Unformatted text preview:

Real Time Operating Systems Lecture 1 1 Objectives Parallel processing distributed processing multithreading Modular programming Call graphs Flow charts Data flow graphs Device drivers serial port uVision4 compiler Quality software Open uart echo Draw a call graph Draw a data flow graph Open UART2 4F120 Draw a call graph Draw a data flow graph Highlight the serial port input and output A How to do decimal input output 1 Write your own like UART2 2 Use sprintf to create strings then output string 3 Link to Standard library function printf Your putchar is your implementation that outputs one byte fputc ttywrch are mapped to Your putchar Standard library function getchar Your getchar is your implementation that input fgetc is mapped to Your getchar Look at the style of ST7735 4F120 by Jonathan W Valvano Real Time Operating Systems Lecture 1 2 B How much driverlib code do you use driverlib code will have fewer bugs than any you or I write You will have to certify all code having no critical sections Most students will want to fit code into 32k All students must understand everything Why private versus public Information hiding Reduce coupling Separate mechanisms from policy Essence of modular design How in C Public name has Module Name and underline Public object has Prototype in header file Private globals have static modifier Use call graphs to identify potential conflicts Module 3 Channel 3 GPIOB Module 7 Channel 7 GPIOB Flowcharts Sequence Conditional While loop Block 1 Block 2 Block 1 Block 2 Block Figure 2 1 Flowchart showing the basic building blocks of structured programming by Jonathan W Valvano Real Time Operating Systems Lecture 1 3 Parallel Distributed Fork Join Interrupt driven concurrent Trigger main interrupt main1 main2 Init1 Init2 Init Body1 Body2 Body Return from interrupt Figure 2 2 Flowchart symbols to describe parallel distributed and concurrent programming See FIFO xxx zip Fifo Put Fifo Get PutPt GetPt PutPt Retreive data at GetPt GetPt tempPt PutPt Store data at tempPt tempPt within buffer tempPt beyond buffer Reset tempPt return 0 within buffer GetPt beyond buffer Reset GetPt GetPt tempPt GetPt return 1 PutPt tempPt return 1 empty full return 0 Figure 3 19 Flowcharts of the pointer implementation of the FIFO queue Two index implementation of the FIFO can hold 0 to FIFOSIZE elements define FIFOSIZE 16 must be a power of 2 define FIFOSUCCESS 1 define FIFOFAIL 0 Two pointer implementation of the FIFO can hold 0 to FIFOSIZE 1 elements define FIFOSIZE 16 can be any size define FIFOSUCCESS 1 define FIFOFAIL 0 typedef char dataType unsigned long volatile PutI put next unsigned long volatile GetI get next dataType static Fifo FIFOSIZE typedef char dataType dataType volatile PutPt put next dataType volatile GetPt get next dataType static Fifo FIFOSIZE void Fifo Init void this is critical should make atomic PutI GetI 0 Empty end of critical section void Fifo Init void this is critical should make atomic PutPt GetPt Fifo 0 Empty end of critical section by Jonathan W Valvano Real Time Operating Systems return FIFOSUCCESS if successful int Fifo Put dataType data if PutI GetI FIFOSIZE 1 return FIFOFAIL Failed fifo full Fifo PutI FIFOSIZE 1 data put PutI Success update return FIFOSUCCESS return FIFOSUCCESS if successful int Fifo Get dataType datapt if PutI GetI return FIFOFAIL Empty if PutI GetI datapt Fifo GetI FIFOSIZE 1 GetI Success update return FIFOSUCCESS number of elements currently stored 0 to FIFOSIZE 1 unsigned short Fifo Size void return unsigned short PutI GetI Lecture 1 4 int Fifo Put dataType data dataType volatile nextPutPt nextPutPt PutPt 1 if nextPutPt Fifo FIFOSIZE nextPutPt Fifo 0 wrap if nextPutPt GetPt return FIFOFAIL Failed fifo full else PutPt data Put PutPt nextPutPt Success update return FIFOSUCCESS int Fifo Get dataType datapt if PutPt GetPt return FIFOFAIL Empty if PutPt GetPt else datapt GetPt if GetPt Fifo FIFOSIZE GetPt Fifo 0 wrap return FIFOSUCCESS Program 3 3 Two pointer implementation of a FIFO How do you make an object in C Polymorphic Inheritance Encapulation define AddFifo NAME SIZE TYPE SUCCESS FAIL unsigned long volatile PutI NAME unsigned long volatile GetI NAME TYPE static Fifo NAME SIZE void NAME Fifo Init void PutI NAME GetI NAME 0 int NAME Fifo Put TYPE data if PutI NAME GetI NAME SIZE 1 return FAIL Fifo NAME PutI NAME SIZE 1 data PutI NAME return SUCCESS int NAME Fifo Get TYPE datapt if PutI NAME GetI NAME return FAIL by Jonathan W Valvano Real Time Operating Systems Lecture 1 5 datapt Fifo NAME GetI NAME SIZE 1 GetI NAME return SUCCESS AddFifo Tx 32 unsigned char 1 0 Data Flow graphs Consumer RxFifo Put RxFifo Get InChar Rx ISR RxFifo main Producer TxFifo Get TxFifo Put OutChar Producer UART input Consumer Tx ISR TxFifo UART output Figure 3 3 A data flow graph showing two FIFOs that buffer data between producers and consumers FIFO queues can be used to pass data between threads Input ISR Input Read data from input Empty RxFifo Not empty RxFifo Get return Output ISR RxFifo Output Full RxFifo Put ERROR Empty TxFifo Get Full Not full TxFifo Not empty TxFifo Not full TxFifo Put Write data to output Arm output return Volume 2 Figure 5 4 In a producer consumer system FIFO queues can be used to pass data between threads by Jonathan W Valvano Disarm output Real Time Operating Systems Lecture 1 6 I O bound input device Input device busy done Interrupt service routine busy done b Main program b a Elements in FIFO c empty d 1 a c d a empty 1 empty Volume 2 Figure 5 6 Hardware software timing of an I O bound input interface I O bound output device buffered I O Output device disarmed done Interrupt service routine busy c Main program a Elements in FIFO empty b done disarmed done d 1 empty done c b a busy d a 1 empty Volume 2 Figure 5 8 Hardware software timing of a CPU bound output interface Parallel processing multiple processors shared memory simultaneous execution of two or more software tasks e g multicore Pentium by Jonathan W Valvano Real Time Operating Systems Buf 0 Buf 1 x Buf 0 Lecture 1 7 Buf 0 Buf 1 Buf 2 Buf 3 y Buf 2 x Buf 1 x y Buf 2 Buf 3 y Buf 3 x y max x max y Distributed processing multiple computers separate memory I O network link simultaneous execution of two or more software tasks e g Lab 6 A Ethernet B A B C Ethernet switch Figure 9 14 Ethernet has a bus based topology by Jonathan W Valvano D Real Time Operating Systems Lecture 1 8 CAN bus LM3S8962 CAN0 SendData Switch ID 4 ID 2 CAN0 GetMail NonBlock LED CAN CAN ISR


View Full Document

UT EE 345M - Real Time Operating Systems Lecture 1.1

Loading Unlocking...
Login

Join to view Real Time Operating Systems Lecture 1.1 and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Real Time Operating Systems Lecture 1.1 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?