Programming Concepts PDF
Programming Concepts PDF
Radek Pelanek
Concurrency Communication and Synchronization RT Facilities
Plan
Concurrent Programming
Concurrent Programming
Concurrent Programming
Concurrent Programming
Automatic Interleaving
Concurrent Programming
Concurrent Programming
Concurrent Programming
Variation
Concurrent programming languages differ in:
structure:
static: the number of processes fixed and known at
compile time
dynamic: processes created at run-time
level:
flat: processes are defined only at the outermost level of
the program
nested: processes are allowed to be defined within
another processes
granularity:
coarse: few long-lived processes
fine: many short-lived processes
Concurrency Communication and Synchronization RT Facilities
About Processes...
what is process
process vs thread
lifecycle of a process creation, termination
interprocess relations
Concurrency Communication and Synchronization RT Facilities
Process
Thread
Process States
Concurrency Communication and Synchronization RT Facilities
Process Representation
Process Termination
Interprocess Relations
Process States II
Concurrency Communication and Synchronization RT Facilities
Source: G. Holzmann
Concurrency Communication and Synchronization RT Facilities
Source: G. Holzmann
Concurrency Communication and Synchronization RT Facilities
Source: G. Holzmann
Concurrency Communication and Synchronization RT Facilities
Source: G. Holzmann
Concurrency Communication and Synchronization RT Facilities
Puzzle
c := 1, x1 := 0, x2 := 0
x1 := c x2 := c
x1 := x1 + c k x2 := x2 + c
c := x1 c := x2
synchronization
satisfaction of constraints on the interleaving
of actions of processes
e.g., action by one process occurring after an
action by another
communication
the passing of information from one process
to another
Concurrency Communication and Synchronization RT Facilities
Linked concepts:
communication requires synchronization
synchronization contentless communication
Concurrency Communication and Synchronization RT Facilities
Data Communication
shared variables
message passing
Concurrency Communication and Synchronization RT Facilities
Shared Variables
Shared Variables
Avoiding Interference
Shared Variables
Shared Variables
Mutual Exclusion
Shared Variables
Semaphores
Shared Variables
Criticism of Semaphores
Shared Variables
Monitores
Shared Variables
Monitors
Message Passing
Message Passing
Synchronous Messages
Concurrency Communication and Synchronization RT Facilities
Message Passing
Asynchronous Messages
Concurrency Communication and Synchronization RT Facilities
Message Passing
Message Passing
(in)direction
direct naming: send msg to process-name
indirect naming: send msg to mailbox
symmetry
symmetric: both sender and receiver name each other
asymmetric: receiver names no specific source
Concurrency Communication and Synchronization RT Facilities
General Remarks
General Remarks
What Time?
units?
seconds, milliseconds, cpu cycles, system ticks, ...
since when?
Christs birth, Jan 1 1970, system boot, program start,
explicit request, ...
real time, cpu time, ...
resolution
Concurrency Communication and Synchronization RT Facilities
General Remarks
Importance of Units
General Remarks
General Remarks
Access to Clock
General Remarks
Delays
Delays
Delays
Concurrency Communication and Synchronization RT Facilities
Delays
while (1) {
delay(100);
do_work();
}
Delays
while (1) {
delay(100);
do_work();
}
Delays
Accumulating Drift
Delays
Accumulating Drift II
Delays
Delays
Timeouts
Delays
Summary