










































Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!











































2.1 The Process Notion2 2 Defining and Instantiating Processes2.2 Defining and Instantiating Processes
Dynamic Creation With fork And join
2.3 Basic Process Interactions
Competition: The Critical Section Problem
2.4 Semaphores
2 5 Event Synchronization2.5 Event Synchronization CompSci 143A
Spring, 2009
A process is the activity of executing a program
Al
ll d
t^
k
on a CPU. Also, called a task.
-^
Conceptually…– Each process has its own CPU
Each process has its own CPU
Physical concurrency = parallelismThi
i^
lti l
This requires multiple CPUs
-^
Logical concurrency = time-shared CPU
-^
Processes cooperate (shared memory messagesProcesses cooperate (shared memory, messages,synchronization)
-^
Processes compete for resources CompSci 143A
Spring, 2009
Defining/Instantiating ProcessesDefining/Instantiating
Processes
Specify precedence relations: when processesstart executing and stop executing, relative toeach other
Spring, 2009
Specifying precedence relations
p
y
g p
CompSci 143A
Spring, 2009
CompSci 143A
Figure 2-1Spring, 2009
(a + b) * (c + d) - (e / f)
gives rise to
(a + b)
(c + d)
(e / f)
gives rise to
Figure 2-
CompSci 143A
Figure 2 2Spring, 2009
-^
Serial execution•
Expressed as S(p1 p
)
-^
Expressed as S(p1, p2, …)
-^
Execute p1, then p2, then …
Parallel executionParallel execution•
Expressed as P(p1, p2, …)
-^
Concurrently execute p1, p2,
y^
p^
p
-^
CompSci 143A
Spring, 2009
CompSci 143A
Figure 2-1Spring, 2009
Process CreationProcess
Creation
b
i^
d
cobegin // coend
statement
Spring, 2009
CompSci 143A
Spring, 2009
Figure 2-
cobeginTime Date // Mail //
g
e_
ate //
a^
//
{^
Edit;cobegin{
Compile; Load; Execute} // {^
Edit; cobegin Print // Web coend} {^
Edit; cobegin Print // Web coend} coend } coend CompSci 143A
Spring, 2009
t^
f^
ll (
t^
t t
t
P
if
f d
i
CompSci 143A
Spring, 2009
Spring, 2009
Explicit program creation:
fork/join
Explicit
program creation:
fork/join
cobegin/coend
are limited to
properly nested
cobegin/coend
are
limited to
properly
nested
graphs
forall
is limited to
data parallelism
p
fork/join
can express
arbitrary functional
parallelism
any process flow graph)
p
y p
g
p )
CompSci 143A
Spring, 2009