Prerequisite – Introduction of Process Synchronization
PARBEGIN/PAREND statement is a higher-level language construct for specifying concurrency. All statements can be executed concurrently those are enclosed between PARBEGIN and PAREND. It is used in modelling precedence graph. It is used as an alternative for the FORK/JOIN statement.
PARBEGIN/PAREND is also called COBEGIN/COEND.
Consider the following program:
S0; PARBEGIN; S1; S2; ... Sn-1; PAREND; Sn;
The above program is equivalent to the following precedence graph.
Construct the precedence graph for the following parbegin/parend program.
begin S1; parbegin S3; begin S2; parbegin S4; S5; parend; S6; end; parend; S7; end;
We can also Parbegin two process –
Void P( ) Void Q( )
The relative order among the statements of P & Q is always maintained
Advantages of Parbegin/Parend –
- It is a high-level language block-structure.
- It has the advantage of structured control statements.
- Semaphores mechanism is also one of the advantages.
Disadvantages of Parbegin/Parend –
- It is not powerful enough to model all possible precedence graph.
- It is less powerful than the FORK/JOIN construct in modelling precedence graph.