The Fork & Join Constructs | Operating System - Computer Science Engineering (CSE) PDF Download

Fork and Join Constructs in Concurrency


Fork

The fork instruction is the that instruction in the process execution that produces two concurrent executions in a program. One of the concurrent executions starts at statement labeled and other execution is the continuation of the execution at the statement following the fork instruction. The fork systems call assignment has one parameter i.e. Label (L).

Join

The join instruction is the that instruction in the process execution that provides the medium to recombine two concurrent computations into a single one. The join instruction has one parameter integer count that specifies the number of computations which are to be joined. It decrements the integer by one. If the value of the integer after decrement is non-zero then the process terminates otherwise the process continues execution with the next statement.

Example 1:
Construct the precedence graph for the following fork/join program.
S1;
     count1: = 2;
     fork L1;
     S2;
     S4;
     count2: = 2;
     fork L2;
     S5;
     Go to L3;
L1:  S3;
L2:  join count1;
     S6;
L3:  join count2;
     S7;
Solution:

The Fork & Join Constructs | Operating System - Computer Science Engineering (CSE)

Example 2:
Write a fork/join program for the following precedence graph.

The Fork & Join Constructs | Operating System - Computer Science Engineering (CSE)

Solution:
After S1 fork statement is required to create a child.
After S4 fork statement is required to create a child.
All processes need to join before S7.
S1;
     count: = 3;
     fork L1;
     S2;
     S4;
     fork L2;
     S5;
     Go to L3;
L2:  S6;
     GOTO L3;
L1:  S3;
L3:  join count;
     S7;

The document The Fork & Join Constructs | Operating System - Computer Science Engineering (CSE) is a part of the Computer Science Engineering (CSE) Course Operating System.
All you need of Computer Science Engineering (CSE) at this link: Computer Science Engineering (CSE)
10 videos|99 docs|33 tests
10 videos|99 docs|33 tests
Download as PDF

Top Courses for Computer Science Engineering (CSE)

Related Searches

Sample Paper

,

Extra Questions

,

Semester Notes

,

Viva Questions

,

practice quizzes

,

MCQs

,

study material

,

The Fork & Join Constructs | Operating System - Computer Science Engineering (CSE)

,

ppt

,

The Fork & Join Constructs | Operating System - Computer Science Engineering (CSE)

,

mock tests for examination

,

The Fork & Join Constructs | Operating System - Computer Science Engineering (CSE)

,

shortcuts and tricks

,

past year papers

,

Summary

,

Exam

,

Previous Year Questions with Solutions

,

Objective type Questions

,

pdf

,

Important questions

,

video lectures

,

Free

;