Docsity

Process Structure and Synchronization in Computer Science: A Spring 2009 Course Overview -, Study notes of Computer Science

Toggle sidebar
bg1
2 Processes and Interactions
2
.
Processes
and
Interactions
2.1 The Process Notion
2 2 Defining and Instantiating Processes
2
.
2
Defining
and
Instantiating
Processes
– Precedence Relations
– Implicit Process Creation
Dynamic Creation With fork And join
–
Dynamic
Creation
With
fork
And
join
– Explicit Process Declarations
2.3 Basic Process Interactions
Competition: The Critical Section Problem
–
Competition:
The
Critical
Section
Problem
– Cooperation
2.4 Semaphores
–
Semaphore Operations and Data
–
Semaphore
Operations
and
Data
– Mutual Exclusion
– Producer/Consumer Situations
2 5 Event Synchronization
2
.
5
Event
Synchronization
CompSci 143A 1
Spring, 2009
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20
pf21
pf22
pf23
pf24
pf25
pf26
pf27
pf28
pf29
pf2a
pf2b
pf2c
pf2d
pf2e
pf2f
pf30
pf31
pf32

Partial preview of the text

Download Process Structure and Synchronization in Computer Science: A Spring 2009 Course Overview - and more Study notes Computer Science in PDF only on Docsity!

2 Processes and Interactions 2

. Processes and Interactions

2.1 The Process Notion2 2 Defining and Instantiating Processes2.2 Defining and Instantiating Processes

  • Precedence Relations– Implicit Process Creation

Dynamic Creation With fork And join

  • Dynamic Creation With fork And join– Explicit Process Declarations

2.3 Basic Process Interactions

Competition: The Critical Section Problem

  • Competition: The Critical Section Problem– Cooperation

2.4 Semaphores

  • Semaphore Operations and Data– Semaphore Operations and Data– Mutual Exclusion– Producer/Consumer Situations

2 5 Event Synchronization2.5 Event Synchronization CompSci 143A

Spring, 2009

ProcessesProcesses

•^

A process is the activity of executing a program

CPU

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

  • Processes are running concurrently -^

Physical concurrency = parallelismThi

i^

lti l

CPU

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

  • Need to

Need to– Define what each process does– Specify precedence relations: when processes

Specify precedence relations: when processesstart executing and stop executing, relative toeach other

  • Create processes CompSci 143A

Spring, 2009

Specifying precedence relations

p

y

g p

  • Process-flow graphs (unrestricted)

g

p

(^

  • Properly nested expressions/graphs (also

known as series-parallel graphs)known as series parallel graphs)

CompSci 143A

Spring, 2009

Examples of Precedence RelationshipsExamples

of Precedence Relationships

(Process Flow Graphs)

CompSci 143A

Figure 2-1Spring, 2009

Process flow graphsProcess

flow graphs

(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

Properly nested expressionsProperly

nested expressions

-^

Two primitives which can be nested:Two primitives, which can be nested:–^

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

-^

A graph is properly nested if it correspondsto a properly nested expressionto a properly nested expression

CompSci 143A

Spring, 2009

Examples of Precedence RelationshipsExamples

of Precedence Relationships

(Process Flow Graphs)

CompSci 143A

Figure 2-1Spring, 2009

Process CreationProcess

Creation

  • Implicit process creation

b

i^

d

cobegin // coend

  • forall

statement

  • Explicit process creation
    • fork/join– Explicit process declarations/classes CompSci 143A

Spring, 2009

Implicit Process CreationImplicit

Process Creation

  • Processes are created dynamically using

language constructslanguage constructs.

  • Process is not explicitly declared or initiated • cobegin/coend

statement

  • Data parallelism:

forall

statement

p

CompSci 143A

Spring, 2009

cobegin/coend example

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

Data parallelismData

parallelism

  • Same code is applied to different data

Same code is applied to different data

  • The

forall

statement

t^

f^

ll (

t^

)^

t t

t

  • syntax: forall (parameters) statements– Meaning:

P

if

f d

i

  • Parameters specify set of data items• Statements are executed for each item concurrently

CompSci 143A

Spring, 2009

Explicit Process CreationExplicit

Process Creation

  • Using

fork/join

Using

fork/join

  • Explicit process declarations/classesCompSci 143A

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