Thông tin tài liệu:
Real-Time Embedded Multithreading Using ThreadX and MIPS- P14:Although the history of embedded systems is relatively short, 1 the advances andsuccesses of this fi eld have been profound. Embedded systems are found in a vast array ofapplications such as consumer electronics, “ smart ” devices, communication equipment,automobiles, desktop computers, and medical equipment.
Nội dung trích xuất từ tài liệu:
Real-Time Embedded Multithreading Using ThreadX and MIPS- P14 Case Study: Designing a Multithreaded System 265 change this value without affecting our design. In addition to the actual data for the event, the protected memory must store the priority and time of the event’s occurrence. This information is essential in the case where the protected memory becomes full and another event is detected or manually triggered. An event can never overwrite a higher- priority event, but it can overwrite an event with the same or lower priority. Figure 14.7 summarizes the event overwrite rules. As stated previously, when the G-force sensors detect a crash, the system generates an interrupt with event priority 1. Unsafe driving events are logged as event priority 2, Priority Time Data: Audio, Video, G-Forces Figure 14.6: Protected memory Priority Overwrite Rule When Protected Memory is Full Overwrite the oldest event of Priority 4. If no Priority 4 event exists, overwrite the oldest event of Priority 3. 1 If no Priority 3 event exists, overwrite the oldest event of Priority 2. If no Priority 2 event exists, overwrite the oldest event of Priority 1. Overwrite the oldest event of Priority 4. If no Priority 4 event exists, overwrite the oldest event of Priority 3. 2 If no Priority 3 event exists, overwrite the oldest event of Priority 2. If no Priority 2 event exists, do not save the new event. Overwrite the oldest event of Priority 4. 3 If no Priority 4 event exists, overwrite the oldest event of Priority 3. If no Priority 3 event exists, do not save the new event. Overwrite the oldest event of Priority 4. 4 If no Priority 4 event exists, do not save the new event. Figure 14.7: Event overwrite rules w w w.ne w nespress.comPlease purchase PDF Split-Merge on www.verypdf.com to remove this watermark. 266 Chapter 14 warnings as event priority 3, and manual events (pushing the emergency button) as event priority 4. Our objective is to respond to these events (which will appear to the system as interrupts), as well as to handle initialization and to process routine data. 14.4 Design of the System Our design will be simplified and will concentrate on control issues. In this section, we will consider thread design issues, and public resources design. We will assume that other processes will handle4 the actual storing and copying of data. 14.4.1 Thread Design We need a thread to perform various initialization duties such as setting pointers and variables, opening the files for the temporary memory and the protected memory, and establishing communication paths and buffers. We will assign the name initializer to this thread. Figure 14.8 depicts this thread. We need a thread to coordinate the capture and storage of data from the VAM system unit to the temporary memory. This thread manages the transfer of audio, video, and G-force data from the VAM system unit to an internal buffer, and then to the temporary memory. We will assign the name data_capture to this thread. Figure 14.9 illustrates this thread’s operation. Initializer Figure 14.8: Initialization of the VAM system 4 This is a good use of a memory byte pool because space is allocated from the pool only once, thus eliminating fragmentation problems. Furthermore, the memory allocations are of different sizes. w ww. n e w n e s p r e s s .c o mPlease purchase PDF Split-Merge on www.verypdf.com to remove this watermark. Case Study: Designing a Multithreaded System 267 We need four ISRs to handle the detected and triggered events. We need one message queue called event_notice to store information about an event until the copying process begins. We also need one thread to process the copying of data from the temporary memory to the protected memory. We will assign the name event_recorder to this thread. This thread is activated 12 seconds after an event has been detected. At this time, the temporary memory contains the 12 seconds of data preceding the ...