Presentation is loading. Please wait.

Presentation is loading. Please wait.

Embedded Systems Software Architectures C.-Z. Yang Sept.-Dec. 2001.

Similar presentations


Presentation on theme: "Embedded Systems Software Architectures C.-Z. Yang Sept.-Dec. 2001."— Presentation transcript:

1 Embedded Systems Software Architectures C.-Z. Yang http://syslab.cse.yzu.edu.tw/~czyang Sept.-Dec. 2001

2 元智大學資訊工程系 czyang@acm.orgEmbedded Systems - Software Architectures2 Software Architectures When you are designing the embedded software, which architecture will be the most appropriate for the given system?

3 元智大學資訊工程系 czyang@acm.orgEmbedded Systems - Software Architectures3 Decision Factors The most important factor –how much control you need to have over system response. Good response –Absolute response time requirements –The speed of your microprocessor –and the other processing requirements

4 元智大學資訊工程系 czyang@acm.orgEmbedded Systems - Software Architectures4 Some Examples The control of an air conditioner –This system can be written with a very simple software architecture. –The response time can be within a number of tens of seconds. –The major function is to monitor the temperature readings and turn on and off the air conditioner. –A timer may be needed to provide the turn-on and turn-off time.

5 元智大學資訊工程系 czyang@acm.orgEmbedded Systems - Software Architectures5 Some Examples The software design of the control of an air conditioner –A simple assembly program for a low-end microprocessor –Inputs Input buttons Temperature readings Timer readings –Output The on-off control of the air conditioner The power control

6 元智大學資訊工程系 czyang@acm.orgEmbedded Systems - Software Architectures6 Some Examples Digital telephone answering machine –A telephone answering machine with digital memory, using speech compression. –The performance and functions It should be able to record about 30 minutes of total voice. Voice data are sampled at the standard telephone rate of 8kHz. OGM of up to 10 seconds Three basic modes –default/play back/OGM editing mode

7 元智大學資訊工程系 czyang@acm.orgEmbedded Systems - Software Architectures7 Some Examples The class diagram for the answering machine Microphone Line-in Line-out Buttons Speaker Record Lights Controls PlaybackIncoming Message Outgoing Message

8 元智大學資訊工程系 czyang@acm.orgEmbedded Systems - Software Architectures8 Some Examples The state diagram for the controls activate behavior

9 元智大學資訊工程系 czyang@acm.orgEmbedded Systems - Software Architectures9 Some Examples The software design for the answering machine –It must respond rapidly to many different events. –It has various processing requirements. –It has different deadlines and different priorities. A more complex architecture

10 元智大學資訊工程系 czyang@acm.orgEmbedded Systems - Software Architectures10 In This Unit... Four basic software architectures will be discussed: –Round-robin –Round-robin with interrupts –Function-queue-scheduling –Real-time operating system

11 元智大學資訊工程系 czyang@acm.orgEmbedded Systems - Software Architectures11 Round-Robin

12 元智大學資訊工程系 czyang@acm.orgEmbedded Systems - Software Architectures12 Round-Robin Architecture The simplest architecture Device A Device B Device Z

13 元智大學資訊工程系 czyang@acm.orgEmbedded Systems - Software Architectures13 The Simplest Architecture No interrupts No shared data No latency concerns

14 元智大學資訊工程系 czyang@acm.orgEmbedded Systems - Software Architectures14 An Application Digital multimeter –R, I, and V readings –Two probes –A rotary switch

15 元智大學資訊工程系 czyang@acm.orgEmbedded Systems - Software Architectures15 Digital Multimeter The possible pseudo-code

16 元智大學資訊工程系 czyang@acm.orgEmbedded Systems - Software Architectures16 Discussion Timing requirement –Only three I/O devices –No particularly lengthy processing –No tight response requirements Emergency control –No such requirements –Users are unlikely to notice the few fractions of a second it takes for the microprocessor to get around the loop

17 元智大學資訊工程系 czyang@acm.orgEmbedded Systems - Software Architectures17 Discussion Advantages –Simplicity –Low development cost –Short development cycle Shortcomings –This architecture cannot handle complex problems.

18 元智大學資訊工程系 czyang@acm.orgEmbedded Systems - Software Architectures18 Shortcomings If any one device needs response in less time –Two possible improvements for the RR architecture Squeezing the loop Carefully arranging the sequence (A,Z,B,Z,C,Z,D,Z,…) If there is any lengthy processing to do –Every other event is also postponed. This architecture is fragile –A single additional device or requirement may break everything.

19 元智大學資訊工程系 czyang@acm.orgEmbedded Systems - Software Architectures19 Round-Robin with Interrupts

20 元智大學資訊工程系 czyang@acm.orgEmbedded Systems - Software Architectures20 Round-Robin with Interrupts A little bit more control –In this architecture, ISR deal with the very urgent needs of the hardware and the set flags. the main loop polls the flags and does any follow-up processing. The ISR can get good response. All of the processing that you put into the ISR has a higher priority than the task code.

21 元智大學資訊工程系 czyang@acm.orgEmbedded Systems - Software Architectures21 A Little Bit More Control You can control the priorities among the ISR as well. The software is more event-driven. Task Code ISR Shared Variables

22 元智大學資訊工程系 czyang@acm.orgEmbedded Systems - Software Architectures22 The Architecture Two main parts Interrupt Service RoutinesThe main loop

23 元智大學資訊工程系 czyang@acm.orgEmbedded Systems - Software Architectures23 RR vs. RR-INT Priority levels

24 元智大學資訊工程系 czyang@acm.orgEmbedded Systems - Software Architectures24 Discussion Advantage –The processing is more effectively. Disadvantage –All of the shared-data problems can potentially jump and bite you.

25 元智大學資訊工程系 czyang@acm.orgEmbedded Systems - Software Architectures25 An Example of A Simple Bridge A device with two ports on it that forwards data traffic received on the first port to the second and vice versa.

26 元智大學資訊工程系 czyang@acm.orgEmbedded Systems - Software Architectures26 Some Assumptions Whenever a character is received on one of the communication links, it causes an interrupt. The Interrupt must be serviced reasonably quickly. Interrupt

27 元智大學資訊工程系 czyang@acm.orgEmbedded Systems - Software Architectures27 Some Assumptions The microprocessor must write characters to the I/O hardware one at a time. The I/O transmitter hardware on that communication ink will be busy while it sends the character. Then it will interrupt to indicate that it is ready for the next character.

28 元智大學資訊工程系 czyang@acm.orgEmbedded Systems - Software Architectures28 Some Assumptions We have routines that will –read characters from and write characters to queues and –test whether a queue is empty or not. These routines can be called from ISRs as well as from the task code. They deal correctly with the shared-data problems.

29 元智大學資訊工程系 czyang@acm.orgEmbedded Systems - Software Architectures29 Possible Code Data structures

30 元智大學資訊工程系 czyang@acm.orgEmbedded Systems - Software Architectures30 Possible Code Interrupt service routines Interrupts upon receiving characters Interrupts upon sending characters

31 元智大學資訊工程系 czyang@acm.orgEmbedded Systems - Software Architectures31 Possible Code The main loop

32 元智大學資訊工程系 czyang@acm.orgEmbedded Systems - Software Architectures32 Possible Code encrypt() and decrypt()

33 元智大學資訊工程系 czyang@acm.orgEmbedded Systems - Software Architectures33 Another Example: Cordless Bar-code Scanner The cordless bar-code scanner

34 元智大學資訊工程系 czyang@acm.orgEmbedded Systems - Software Architectures34 Characteristics of RR-INT The primary shortcoming –All of the task code executes at the same priority

35 元智大學資訊工程系 czyang@acm.orgEmbedded Systems - Software Architectures35 Characteristics of RR-INT A possible solution –Putting code into the interrupt service routines –However, this may lengthen the response times for the ISRs for low-priority devices. Alternative solution –Changing the testing sequence A,C,B,C,D,C,E,C,… –However, the code is more fragile.

36 元智大學資訊工程系 czyang@acm.orgEmbedded Systems - Software Architectures36 Inappropriate Cases for RR-INT A laser printer –Calculating the locations where the black dots go is very time-consuming. –In RR-INT architecture, the only code that will get good response is code in ISR. –Any task code may potentially be stuck while the system calculates more locations for black dots. The underground tank-monitoring system –The code that calculates how much gasoline is in the tanks is very time-consuming.

37 元智大學資訊工程系 czyang@acm.orgEmbedded Systems - Software Architectures37 Function-Queue-Scheduling Architecture

38 元智大學資訊工程系 czyang@acm.orgEmbedded Systems - Software Architectures38 FQS Architecture In this architecture, the interrupt service routines add function pointers to a queue of function pointers. *foo() foo() { } foo() { }

39 元智大學資訊工程系 czyang@acm.orgEmbedded Systems - Software Architectures39 The Framework of FQS Three parts

40 元智大學資訊工程系 czyang@acm.orgEmbedded Systems - Software Architectures40 The FQS Architecture The advantages –No rule says main has to call the functions in the order that the interrupt routines occurred. –Any task code functions that need quicker response can be executed earlier. –All this rakes is a little clever coding in the routines that queue up the function pointers. The worst wait –the length of the longest of the task code function

41 元智大學資訊工程系 czyang@acm.orgEmbedded Systems - Software Architectures41 The FQS Architecture The trade-off –The response for the lower-priority task code functions may get worse. –Lower-priority functions may never execute if the interrupt service schedule the higher-priority functions frequently enough to use up all of the microprocessor’s available time.

42 元智大學資訊工程系 czyang@acm.orgEmbedded Systems - Software Architectures42 Real-Time Operating System Architecture

43 元智大學資訊工程系 czyang@acm.orgEmbedded Systems - Software Architectures43 RTOS Architecture The most sophisticated architecture In this architecture, the ISRs take care of the most urgent operations. Then they “signal” that there is work for the task code to do.

44 元智大學資訊工程系 czyang@acm.orgEmbedded Systems - Software Architectures44 A Paradigm The sample code

45 元智大學資訊工程系 czyang@acm.orgEmbedded Systems - Software Architectures45 The Processing The necessary signaling between the interrupt routines and the task code is handled by RTOS. –No shared variable needs to be used. No loop in our code decides what needs to be done next. –RTOS knows about the various task-code subroutines and will run whichever of them is more urgent. RTOS can suspend a task-code subroutine in the middle of its processing in order to run another.

46 元智大學資訊工程系 czyang@acm.orgEmbedded Systems - Software Architectures46 A Priority-based Scheduling RTOS can control task code response as well as ISR response. The worst-case wait for the highest-priority task code is zero. Therefore, your system’s response will be relatively stable. Another advantage is that RTOSs are widely available for purchase.

47 元智大學資訊工程系 czyang@acm.orgEmbedded Systems - Software Architectures47 Priority Levels A comparison

48 元智大學資訊工程系 czyang@acm.orgEmbedded Systems - Software Architectures48 Disadvantages The RTOS itself uses a certain amount of processing time. –You are getting better response at the expense of a little bit of throughput. Also, the software architecture is much more complex.

49 元智大學資訊工程系 czyang@acm.orgEmbedded Systems - Software Architectures49 Selecting an Architecture

50 元智大學資訊工程系 czyang@acm.orgEmbedded Systems - Software Architectures50 Some Suggestions Select the simplest architecture that will meet your response requirements. –Writing embedded-system software is complicated enough without choosing an unnecessarily complex architecture for your software. if your system has response requirements that might necessitate using a RTOS, you should lean toward using a RTOS.

51 元智大學資訊工程系 czyang@acm.orgEmbedded Systems - Software Architectures51 Some Suggestions If it makes sense for your system, you can create hybrids of the architectures. –Even if you are using a RTOS, you can have a low-priority task that polls those parts of the hardware that do not need fast response. Hybrid architectures make sense for some systems.

52 元智大學資訊工程系 czyang@acm.orgEmbedded Systems - Software Architectures52 The Summary

53 元智大學資訊工程系 czyang@acm.orgEmbedded Systems - Software Architectures53 A Characteristic Table Four architectures


Download ppt "Embedded Systems Software Architectures C.-Z. Yang Sept.-Dec. 2001."

Similar presentations


Ads by Google