0% found this document useful (0 votes)
94 views22 pages

Multitasking Design and Implementation Issues in Embedded Systems

This document summarizes a presentation on multitasking design and implementation issues in embedded systems. The presentation covered basic properties of real-time operating systems (RTOS), including differences between linear code, event loops, multithreading, and full multitasking. It discussed advantages and disadvantages of different approaches and when each is appropriate for embedded systems. Key topics included task communication methods, prioritization, and potential issues like complexity, deadlocks, and using prioritization as a "crutch" for poor system design.

Uploaded by

arunmetha
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
94 views22 pages

Multitasking Design and Implementation Issues in Embedded Systems

This document summarizes a presentation on multitasking design and implementation issues in embedded systems. The presentation covered basic properties of real-time operating systems (RTOS), including differences between linear code, event loops, multithreading, and full multitasking. It discussed advantages and disadvantages of different approaches and when each is appropriate for embedded systems. Key topics included task communication methods, prioritization, and potential issues like complexity, deadlocks, and using prioritization as a "crutch" for poor system design.

Uploaded by

arunmetha
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 22

KATHOLIEKE

UNIVERSITEIT
LEUVEN
DEPT. OF
COMPUTER
SCIENCE

Multitasking Design and


Implementation Issues in
Embedded Systems
ESC Europe 1999 report

by Larry Mittag

1
Overview
KATHOLIEKE
UNIVERSITEIT
LEUVEN
DEPT. OF
COMPUTER
SCIENCE
 Speaker
 Larry Mittag (Stellcom Technologies)
 Presentation
 first part was basic but interesting
 second part: hints & tricks
ESC Europe 1999 report

 no groundbreaking concepts

2
Part 1: Properties of RTOS’s
KATHOLIEKE
UNIVERSITEIT
LEUVEN
DEPT. OF

 Linear code vs. multitasking


COMPUTER
SCIENCE

 Multitasking and multithreading


 Use of multitasking and multithreading in embedded
systems
ESC Europe 1999 report

 Communication
 Priorities

3
In The Beginning: Linear Code
KATHOLIEKE
UNIVERSITEIT
LEUVEN
DEPT. OF
COMPUTER
SCIENCE
 Simple and effective
 Augmented by interrupts
 Preferred method for systems dedicated to simple
tasks
ESC Europe 1999 report

 But this can lead to an overloaded single task

4
Next Step: Event Loops
KATHOLIEKE
UNIVERSITEIT
LEUVEN
DEPT. OF
COMPUTER
SCIENCE

while (1)
{
ESC Europe 1999 report

Do_Task_1();
Do_Task_2();
Do_Task_3();
}

5
Next Step: Event Loops
KATHOLIEKE
UNIVERSITEIT
LEUVEN
DEPT. OF
COMPUTER
SCIENCE
 Allows to handle multiple logical tasks in one thread
 Nice design to keep separate code segments away
from each other
 Can eventually fall victim to complexity
ESC Europe 1999 report

 ad hoc techniques lead to this complexity

6
Asynchronous Multitasking
KATHOLIEKE
UNIVERSITEIT
LEUVEN

 Provides a finer degree of sharing of the CPU


DEPT. OF
COMPUTER
SCIENCE

 Relieves the programmer of the need to `order`


different tasks
 Complex in sense of
 design
ESC Europe 1999 report

 debugging

7
Multitasking Flavors
KATHOLIEKE
UNIVERSITEIT
LEUVEN
DEPT. OF
COMPUTER
SCIENCE
 Lightweight multitasking
 another word for multithreading
 Heavy-duty multitasking
ESC Europe 1999 report

8
Lightweight Tasking: Threads
KATHOLIEKE
UNIVERSITEIT
LEUVEN
DEPT. OF
COMPUTER
SCIENCE
 Address and global name space shared among tasks
 Separate stacks, so local variables are not shared
 Very fast context switches
 only need to save registers and stack pointer
 No memory management required
ESC Europe 1999 report

 no need to dereference pointers

9
Monolithic Load Module
KATHOLIEKE
UNIVERSITEIT
LEUVEN
DEPT. OF
COMPUTER
SCIENCE
 All (or most) references resolved at link time
 Difficult to add load modules at runtime
 Very simple and fast
ESC Europe 1999 report

10
Heavy-Duty Multitasking
KATHOLIEKE
UNIVERSITEIT
LEUVEN

 Each task has a separate virtual address space


DEPT. OF
COMPUTER
SCIENCE

 Also a separate global name space


 Generally requires memory management unit on
CPU
ESC Europe 1999 report

11
Dynamic Load Capability
KATHOLIEKE
UNIVERSITEIT
LEUVEN
DEPT. OF
COMPUTER  Allows new tasks to be loaded from disk or
SCIENCE
communications link
 Requires virtual memory, position-independent code,
or trickery
 Not necessary in many systems, required in others
ESC Europe 1999 report

12
Pros and Cons of Multithreading
KATHOLIEKE
UNIVERSITEIT
LEUVEN
DEPT. OF
COMPUTER
SCIENCE
 Pro
 Simple, fast multitasking
 Easy, fast communications through global variables
 Contra
 difficult to implement dynamic loading
ESC Europe 1999 report

 a bug can be disastrous

13
Pros and Cons of Multitasking
KATHOLIEKE
UNIVERSITEIT
LEUVEN
DEPT. OF
COMPUTER
SCIENCE
 Pro
 Very easy to build smaller, more easily debugged tasks
 Damage from a misbehaving task can be contained
 Contra
 overhead at runtime
ESC Europe 1999 report

 complex CPU
 may require swap medium

14
Which for Embedded Systems?
KATHOLIEKE
UNIVERSITEIT
LEUVEN
DEPT. OF
COMPUTER
SCIENCE
 In general, go with lightweight threads
 Exceptions:
 Virtual memory required
 Need to use large amounts of ported “workstation” code
 Need to dynamically load external code
ESC Europe 1999 report

15
When NOT to Use Multitasking
KATHOLIEKE
UNIVERSITEIT
LEUVEN
DEPT. OF
COMPUTER
SCIENCE  Small, simple applications
 Applications that need to be validated
 When determinism is important
ESC Europe 1999 report

16
Communications
KATHOLIEKE
UNIVERSITEIT
LEUVEN
DEPT. OF

 Shared memory
COMPUTER
SCIENCE

 fast
 but: deadly
 Semaphores
 simple
ESC Europe 1999 report

 but: deadlocks
 Message queues
 decoupling sink and source
 but: out of sync consume/produce rates

17
Task Prioritization: Crutch?
KATHOLIEKE
UNIVERSITEIT
LEUVEN
DEPT. OF

 Prioritization allows the specification of the relative


COMPUTER
SCIENCE

importance of tasks
 Can be very important - allows the use of
“background” processing
 Also can act as a crutch for a poor system design
ESC Europe 1999 report

 last moment solutions


 politics

18
Why Prioritize?
KATHOLIEKE
UNIVERSITEIT
LEUVEN
DEPT. OF
COMPUTER  Creates hierarchies of task importance
SCIENCE

 Gives critical functions a better chance of being


deterministic
 One more way the programmer can exert control
over the system
ESC Europe 1999 report

19
Priority Overkill
KATHOLIEKE
UNIVERSITEIT
LEUVEN
DEPT. OF

 More than 3 or 4 levels are rarely useful


COMPUTER
SCIENCE

 Overuse can cause inadequate levels of task


switching
 Potential result: Poor response time
ESC Europe 1999 report

20
Rules for Sane Prioritization
KATHOLIEKE
UNIVERSITEIT
LEUVEN
DEPT. OF
COMPUTER
SCIENCE  Divide the tasks into time-critical and non time
critical
 Among critical tasks, give short-duration tasks
higher priority
ESC Europe 1999 report

 Allow your system to be a little out-of-control

21
Part II: Designing Multitasking
KATHOLIEKE
Systems
UNIVERSITEIT
LEUVEN
DEPT. OF
COMPUTER
SCIENCE

 Selecting an RTOS
 Partitioning tasks
 Communications and synchronization
ESC Europe 1999 report

 Adjusting tasking parameters


 Debugging techniques for tasks
 Grab-Bag of stuff

22

You might also like