10
Concurrent Execution CS561 Computer Architecture Hye Yeon Kim

Concurrent Execution

Embed Size (px)

DESCRIPTION

Concurrent Execution. CS561 Computer Architecture Hye Yeon Kim. Chapter topics. Processes represent independent threads of control, each of which executes sequential code. Process creation declaration Unabbreviated form of processes Concurrent invocation statement - PowerPoint PPT Presentation

Citation preview

Page 1: Concurrent Execution

Concurrent Execution

CS561 Computer Architecture

Hye Yeon Kim

Page 2: Concurrent Execution

Chapter topicsChapter topics

• Processes – represent independent threads of control,

each of which executes sequential code.

• Process creation – declaration– Unabbreviated form of processes– Concurrent invocation statement

• Process scheduling & priorities

Page 3: Concurrent Execution

Processes Declarations• Processes in a resources or global are created

when the resource or global is created.• Processes are created as their declarations are

encountered in executing the resource's or global’s initial code. (the initial code continues as soon as a process is created. It does not wait for the process to terminate.)

• For process declarations that contains quantifiers, one instance of the process is created for each combination of values of the bound variables.

Page 4: Concurrent Execution

Non- deterministic execution

the order of the p1, p2 execution is not known

write(“in p1”,x) # added to process p1write (“in p2”,x) # added to process p2

The output from one write will not one interleaved with the output from the other.

Page 5: Concurrent Execution

• Program with multiple processes terminates when all processes have terminated, a deadlock has occurred, or a stop statement is executed.

• Any final code in the main resource is then executed, and globals imported by the main resources are destroyed (unless a stop statement is executed with a non-zero exit status)

Page 6: Concurrent Execution

Unabbreviated form of processes• When processes need to be created as a program executes,

we can use unabbreviated forms.

• proc and send invocation has been abbreviated in process declaration.

• send: a asynchronous invocation (i.e. non-blocking)

• call: a synchronous invocation (i.e. blocking)

• a send does not wait for the invoked proc to return any results; it terminates immediately after passing the arguments to the proc. A new process is created to execute the proc; it executes in parallel with the process that executed send

Page 7: Concurrent Execution

Concurrent invocation without postprocessing code

• co p(3) // q() // a:= r(x,y) oc

• final invocation assigns the value that r returns to a.

• It terminates when all invocations terminates.

Page 8: Concurrent Execution

Concurrent invocation

• It consists of one or more concurrent commands separated by // delimiters:

• co concurrent_command // concurrent_command // ... oc

• Each concurrent command consists of an invocation and optional block of postprocessing code.

• Invocation or invocation -> block

Page 9: Concurrent Execution

Concurrent invocation with postprocessing code

• All invocations are first started in parallel. Then as each invocation terminates, the corresponding postprocessing block is executed, if there is one.

• Postprocessing blocks are executed one at a time; they are not executed concurrently and thus can change variables without requiring mutual exclusion.

Page 10: Concurrent Execution

Process scheduling & priorities

• setproirity function