Title: Designing Concurrency
1Designing Concurrency
- Software Engineering issues with regards to the
development of concurrent systems
2Placing concurrency
- Very much associated with R-T systems
- In high regard within control systems
- Regarded with intimidation by many s/w developers
- Should be reflected in all phases of s/w
development - especially in the initial ones - A lot of scheduling theory (already covered)
assumed concurrent tasks
3Some aspects of concurrent systems
- Multitasking support
- Scheduling concerns
- Time responsiveness
- Task priorities
- Resource sharing
- Task synchronisation
4Ways of running concurrent tasks (1)
- Sequential (fixed) execution
- Pros
- Tasks are periodic with periods T1 T2 T3
t1 t2 t3 - Easy to implement
- No context switching (1 processor 1 sequential
chunk) - Easily visible control structure
- Cons
- Low time response control
- Could lead to task execution failure
5Ways of running concurrent tasks (2)
- Time sliced (shared) execution
6Ways of running concurrent tasks (3)
- Software supported multitasking
Run-time software support
7The functions of run-time support software
- Basic functions
- Create new tasks (define a task within system
framework) - Task activation (make a task runnable)
- Task management (manage task states)
- Task states
- Running (currently executing)
- Waiting (waiting for its turn to run)
- Suspended (waiting to be ready)
- Terminated (ended normally or abnormally)
8Ways of running concurrent tasks (4)
- Using co-routines (see Modula2 / 3 programming
language) - Better mimic the concept of time sliced execution
- No master-slave assumptions (as in normal
sub-routines) - Once started it need not necessarily terminate
before relinquishing control to its original
caller
9Ways of running concurrent tasks (5)
- Task scheduler (control over when tasks are made
active)
Task scheduler
10Ways of running concurrent tasks (6)
- Task prioritisation
- This topic was covered in the Real-Time part of
this course. - No further discussion will be undertaken at this
point.
11Ways of running concurrent tasks (7)
- Using interrupts to control tasks (earliest form
of scheduling) - In limited memory capacity systems
- In very fast (response) systems
- Some cons of such systems
- Only interrupt driven tasks
- Awareness of interrupt
- organisation
- Awareness of the hard-
- ware system which is to
- host it.
12Co-operation between concurrent tasks
- The main problems arising from task co-operation
- Mutual exclusion problem
- This implies task requirement for exclusive
usage of a resource shared by other tasks (common
resource) - Task synchronisation problem
- This arises from the fact that independent tasks
are not necessarily non-co-operating tasks. If
tasks co-operate in any way, then they require
some form of synchronisation - The producer/consumer problem
- This problem relates to the passage
(communication) of data between tasks. Data sent
is produced while data received is consumed.
13The mutual exclusion problem
- Imagine 2 processes having to write the word
hello (indefinitely) to a screen. Assume that
the one writes the string he and the other
writes the string llo.
PN markings p1 String he available p2
String llo available p3 String he
displayed p4 String llo displayed. Transition
functions t1 Display he t2 Display
llo t3 Compute he t4 Compute llo.
14Solutions to the mutual exclusion problem
- Single flag method
- Method by which critical areas (i.e. parts of
code accessing shared resources) is signalled by
a simple indicator (flag). Flag up means in use,
flag down - free. - Use of the priority ceiling protocol
- This is the same as was explained in the R-T part
of this course. Please refer to that material. - Use of semaphores (both of binary and counting
semaphores) - Basically, a protected variable with 2 associated
operations - wait and signal (usually called P
and V)
15The single flag method
- Very easily implemented and understood
(straightforward)