Title: Concurrency
1Concurrency
A _______ is a unit of software that is capable
of executing concurrently with other similar
units.
Synonyms
_______ -- user-defined process in Ada
_________ -- light weight process
____________ -- user processes for O.S.
interaction
2Process Operations
_______ a process
____________ a process
__________ a process
____________ a process
Example a terminal application shell (OS X)
How do you...
1) Create a shell?
2) Start the execution of a shell?
3) Suspend a shell?
4) Destroy a shell?
3Example 2 Unix commands in a C-shell
What suffix is used to cause a Unix command to
run in the background?
What command suspends destroys a running
process?
Example 3 Dijkstras parbegin - parend
parbegin process1 process2
process3 ? ? ? processn parend
4Example 4 Unix script programs
? A fork function creates a child process and
that shares code with the parent.
? Both the child and its parent continue
executing immediately following the fork.
? The fork function returns the child process ID
to its parent and 0 to the child.
? Suspending and resuming process execution is
determined by the O.S.
? Children processes share resources (files,
etc.) with their parent.
? Processes are killed at the end of their code.
? A wait function can be called to suspend a
parent awaiting a child.
sample
childProcessNum fork() if (childProcessNum0)
// child process code goes here else
// parent process code goes here ? ? ? do
finiNum wait(status) while
(finiNum!childProcessNum)
5Example 5 Ada Tasks
? An Ada task is created and begins execution
when its enclosing program unit executes.
? A program terminates only when all its tasks
terminate.
? Each task has a single line of control.
sample
with text_io use text_io procedure Write_em
is task WriteAs task body WriteAs
is begin for j in 1..10
loop put('A') new_line
end loop end WriteAs task
WriteBs task body WriteBs is
begin for j in 1..10 loop
put('B') new_line end
loop end WriteBs begin --
Write_em procedure null -- procedure body
must be have least one instruction end
Write_em