100 likes | 223 Views
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
E N D
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 • Process scheduling & priorities
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.
Non- deterministic executionthe order of the p1, p2 execution is not knownwrite(“in p1”,x) # added to process p1write (“in p2”,x) # added to process p2The output from one write will not one interleaved with the output from the other.
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)
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
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.
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
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.
Process scheduling & priorities • setproirity function