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

Top Courses for Computer Science Engineering (CSE)

10 videos|99 docs|33 tests
Download as PDF
Explore Courses for Computer Science Engineering (CSE) exam

Top Courses for Computer Science Engineering (CSE)

Signup for Free!
Signup to see your scores go up within 7 days! Learn & Practice with 1000+ FREE Notes, Videos & Tests.
10M+ students study on EduRev
Related Searches

Exam

,

Summary

,

mock tests for examination

,

ppt

,

past year papers

,

shortcuts and tricks

,

practice quizzes

,

Viva Questions

,

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

,

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

,

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

,

video lectures

,

Free

,

Previous Year Questions with Solutions

,

MCQs

,

pdf

,

study material

,

Objective type Questions

,

Sample Paper

,

Semester Notes

,

Important questions

,

Extra Questions

;