Download presentation
Presentation is loading. Please wait.
Published byRichard Payne Modified over 9 years ago
2
Ernest Cachia University of Malta “Designing Concurrency” Slide No. 1 - Title Slide Ernest Cachia CSA404 Designing Concurrency Software Engineering issues with regards to the development of concurrent systems
3
Ernest Cachia University of Malta “Designing Concurrency” Slide No. 2 of part 1 Placing 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
4
Ernest Cachia University of Malta “Designing Concurrency” Slide No. 3 of part 1 Some aspects of concurrent systems Multitasking support Scheduling concerns Time responsiveness Task priorities Resource sharing Task synchronisation
5
Ernest Cachia University of Malta “Designing Concurrency” Slide No. 4 of part 1 Sequential (fixed) execution Ways of running concurrent tasks (1) Task 1Task 2Task 3 t2t2 t3t3 Task 1Task 2Task 3 t1t1 t2t2 t3t3 t1t1 … Pros: - Tasks are periodic with periods T 1 = T 2 = T 3 = t 1 + t 2 + t 3 - 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
6
Ernest Cachia University of Malta “Designing Concurrency” Slide No. 5 of part 1 Ways of running concurrent tasks (2) Time sliced (shared) execution ? Task 1Task 2Task 3Task 1Task 2Task 3 … 1 2 3 1 2 3 3 11 AB 22 1 2 3 C 1 2 1 333
7
Ernest Cachia University of Malta “Designing Concurrency” Slide No. 6 of part 1 Ways of running concurrent tasks (3) Software supported multitasking Run-time software support Task 1 Terminator 1 Terminator i Terminator i+1 Terminator n Task 2 Terminator 1 Terminator i Terminator i+1 Terminator n
8
Ernest Cachia University of Malta “Designing Concurrency” Slide No. 7 of part 1 The functions of run-time support software Basic functions: u Create new tasks (define a task within system framework) u Task activation (make a task “runnable”) u Task management (manage task states) Task states: u Running (currently executing) u Waiting (waiting for its turn to run) u Suspended (waiting to be ready) u Terminated (ended normally or abnormally)
9
Ernest Cachia University of Malta “Designing Concurrency” Slide No. 8 of part 1 Ways of running concurrent tasks (4) Using co-routines (see Modula2 / 3 programming language) u Better mimic the concept of time sliced execution u No master-slave assumptions (as in normal sub- routines) u Once started it need not necessarily terminate before relinquishing control to it’s original caller Co-routine 1 (main) Co-routine 2 transfer to co2 transfer to co1start co1transfer to co2transfer to co1 suspendedsusp. suspended susp. … …
10
Ernest Cachia University of Malta “Designing Concurrency” Slide No. 9 of part 1 Ways of running concurrent tasks (5) Task scheduler (control over when tasks are made active) Task scheduler Task 1 Task 2 enable/disable signal System timer System timer
11
Ernest Cachia University of Malta “Designing Concurrency” Slide No. 10 of part 1 Ways 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.
12
Ernest Cachia University of Malta “Designing Concurrency” Slide No. 11 of part 1 Ways of running concurrent tasks (7) Using interrupts to control tasks (earliest form of scheduling) In limited memory capacity systems In very fast (response) systems Task 1 Task 2 Ext. interrupt 1 Ext. interrupt 2 Task 3 Ext. signal Int. timer Task 4 Ext. signal 1 Ext. signal 2 Some cons of such systems: Only interrupt driven tasks Awareness of interrupt organisation Awareness of the hard- ware system which is to host it.
13
Ernest Cachia University of Malta “Designing Concurrency” Slide No. 12 of part 1 Co-operation between concurrent tasks The main problems arising from task co-operation: u Mutual exclusion problem This implies task requirement for exclusive usage of a resource shared by other tasks (common resource) u 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 u The producer/consumer problem This problem relates to the passage (communication) of data between tasks. Data sent is “produced” while data received is “consumed”.
14
Ernest Cachia University of Malta “Designing Concurrency” Slide No. 13 of part 1 The 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”. Process 1Process 2
15
Ernest Cachia University of Malta “Designing Concurrency” Slide No. 14 of part 1 Solutions to the mutual exclusion problem Single flag method u 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 u 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)
16
Ernest Cachia University of Malta “Designing Concurrency” Slide No. 15 of part 1 The single flag method Very easily implemented and understood (straightforward) 00000011 Task 1 Task 2 flag down = 0 … … 1 1 1 … Resource 1 flag up = 1
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.