SlideShare a Scribd company logo
Write a C program using fork() alone to mimic the below below observations. Consider the
following statements: S2 S1 z 1 S3 c a b; S3 S 4 d C-1; S4 The corresponding Precedence graph
is as shown above
Solution
In the above description we are having statements execute parallely. This is because, the system
may have multiple CPUs or floating point units which compute at the same time as CPU.
Problem is some statements must be completed before others begun.
And to construct these type of statements we are using fork(). Fork() look like fork label and
splits process into two, which is starting at the label and other is which is falling through.
fork L;
a:=x+y;
...
L: :b=z+1;
Fork() system call is used for creating Processes. It returns process ID. It creates new process
which is the child process of the caller.
Along with Fork() we can use parallel construct Join().
Join() merges processes and has count label.
Count will zero if there is a branch at label.
count :=count - 1;
if count =0 then goto label;
Now for above precedence graph, code will be as below:
count=2;
fork dopar;
a:= x+y;
goto donepar;
dopar: b:=z+1
donepar: join count, cont;
quit;
cont: c:=a+b;
d:=c-1;
Strengths using fork() system call is, simple, powerful, easy to derive from precedence graphs.

More Related Content

Similar to Write a C program using fork() alone to mimic the below below observ.pdf

3 algorithm-and-flowchart
3 algorithm-and-flowchart3 algorithm-and-flowchart
3 algorithm-and-flowchart
Rohit Shrivastava
 
Class 12 computer sample paper with answers
Class 12 computer sample paper with answersClass 12 computer sample paper with answers
Class 12 computer sample paper with answers
debarghyamukherjee60
 
Complete C programming Language Course
Complete C programming Language CourseComplete C programming Language Course
Complete C programming Language Course
Vivek chan
 
Lecture1-Algorithms-and-Flowcharts-ppt.ppt
Lecture1-Algorithms-and-Flowcharts-ppt.pptLecture1-Algorithms-and-Flowcharts-ppt.ppt
Lecture1-Algorithms-and-Flowcharts-ppt.ppt
ReshuReshma8
 
Os2 2
Os2 2Os2 2
Os2 2issbp
 
Functions in c++
Functions in c++Functions in c++
Functions in c++
Srikanth Mylapalli
 
C programming languag for cse students
C programming languag for cse studentsC programming languag for cse students
C programming languag for cse students
Abdur Rahim
 
basics of C and c++ by eteaching
basics of C and c++ by eteachingbasics of C and c++ by eteaching
basics of C and c++ by eteaching
eteaching
 
1. Ch_1 SL_1_Intro to Matlab.pptx
1. Ch_1 SL_1_Intro to Matlab.pptx1. Ch_1 SL_1_Intro to Matlab.pptx
1. Ch_1 SL_1_Intro to Matlab.pptx
MOHAMMAD SAYDUL ALAM
 
Algorithms and flowcharts
Algorithms and flowchartsAlgorithms and flowcharts
Algorithms and flowcharts
Samuel Igbanogu
 
C introduction
C introductionC introduction
C introduction
MadhuriPareek
 
Introduction to computer_lec_03
Introduction to computer_lec_03Introduction to computer_lec_03
Introduction to computer_lec_03
Ramadan Babers, PhD
 
Adapted from Harris & Harris Digital Design and Computer Arch.docx
Adapted from Harris & Harris Digital Design and Computer Arch.docxAdapted from Harris & Harris Digital Design and Computer Arch.docx
Adapted from Harris & Harris Digital Design and Computer Arch.docx
nettletondevon
 
Lab 1.pptx
Lab 1.pptxLab 1.pptx
Lab 1.pptx
MohammedAlobaidy16
 
Lecture 1
Lecture 1Lecture 1
Lecture 1
Mohammed Saleh
 
Lecture 1
Lecture 1Lecture 1
Lecture 1
Mohammed Saleh
 
C programming part2
C programming part2C programming part2
C programming part2
Keroles karam khalil
 
C programming part2
C programming part2C programming part2
C programming part2
Keroles karam khalil
 

Similar to Write a C program using fork() alone to mimic the below below observ.pdf (20)

3 algorithm-and-flowchart
3 algorithm-and-flowchart3 algorithm-and-flowchart
3 algorithm-and-flowchart
 
Class 12 computer sample paper with answers
Class 12 computer sample paper with answersClass 12 computer sample paper with answers
Class 12 computer sample paper with answers
 
Complete C programming Language Course
Complete C programming Language CourseComplete C programming Language Course
Complete C programming Language Course
 
Lecture1-Algorithms-and-Flowcharts-ppt.ppt
Lecture1-Algorithms-and-Flowcharts-ppt.pptLecture1-Algorithms-and-Flowcharts-ppt.ppt
Lecture1-Algorithms-and-Flowcharts-ppt.ppt
 
Os2 2
Os2 2Os2 2
Os2 2
 
ICP - Lecture 6
ICP - Lecture 6ICP - Lecture 6
ICP - Lecture 6
 
Functions in c++
Functions in c++Functions in c++
Functions in c++
 
C programming languag for cse students
C programming languag for cse studentsC programming languag for cse students
C programming languag for cse students
 
basics of C and c++ by eteaching
basics of C and c++ by eteachingbasics of C and c++ by eteaching
basics of C and c++ by eteaching
 
Alp 05
Alp 05Alp 05
Alp 05
 
1. Ch_1 SL_1_Intro to Matlab.pptx
1. Ch_1 SL_1_Intro to Matlab.pptx1. Ch_1 SL_1_Intro to Matlab.pptx
1. Ch_1 SL_1_Intro to Matlab.pptx
 
Algorithms and flowcharts
Algorithms and flowchartsAlgorithms and flowcharts
Algorithms and flowcharts
 
C introduction
C introductionC introduction
C introduction
 
Introduction to computer_lec_03
Introduction to computer_lec_03Introduction to computer_lec_03
Introduction to computer_lec_03
 
Adapted from Harris & Harris Digital Design and Computer Arch.docx
Adapted from Harris & Harris Digital Design and Computer Arch.docxAdapted from Harris & Harris Digital Design and Computer Arch.docx
Adapted from Harris & Harris Digital Design and Computer Arch.docx
 
Lab 1.pptx
Lab 1.pptxLab 1.pptx
Lab 1.pptx
 
Lecture 1
Lecture 1Lecture 1
Lecture 1
 
Lecture 1
Lecture 1Lecture 1
Lecture 1
 
C programming part2
C programming part2C programming part2
C programming part2
 
C programming part2
C programming part2C programming part2
C programming part2
 

More from pristiegee

Question No. 2 Describe how the Packet-Filtering Router filter data..pdf
Question No. 2 Describe how the Packet-Filtering Router filter data..pdfQuestion No. 2 Describe how the Packet-Filtering Router filter data..pdf
Question No. 2 Describe how the Packet-Filtering Router filter data..pdf
pristiegee
 
Indicicate the coordinaiton number of the metal and oxidation number.pdf
Indicicate the coordinaiton number of the metal and oxidation number.pdfIndicicate the coordinaiton number of the metal and oxidation number.pdf
Indicicate the coordinaiton number of the metal and oxidation number.pdf
pristiegee
 
QUESTION 12 12. An example of an error of presentation would be e.pdf
QUESTION 12 12. An example of an error of presentation would be e.pdfQUESTION 12 12. An example of an error of presentation would be e.pdf
QUESTION 12 12. An example of an error of presentation would be e.pdf
pristiegee
 
Please need help on C++ language.Infix to Postfix) Write a program.pdf
Please need help on C++ language.Infix to Postfix) Write a program.pdfPlease need help on C++ language.Infix to Postfix) Write a program.pdf
Please need help on C++ language.Infix to Postfix) Write a program.pdf
pristiegee
 
On a Metabolic Pathways experiment, Describe your observations below.pdf
On a Metabolic Pathways experiment, Describe your observations below.pdfOn a Metabolic Pathways experiment, Describe your observations below.pdf
On a Metabolic Pathways experiment, Describe your observations below.pdf
pristiegee
 
Name at least three major contributions of Islamic mathematicians..pdf
Name at least three major contributions of Islamic mathematicians..pdfName at least three major contributions of Islamic mathematicians..pdf
Name at least three major contributions of Islamic mathematicians..pdf
pristiegee
 
Module 02 Discussion - Domestic ContainmentDiscuss the concept of .pdf
Module 02 Discussion - Domestic ContainmentDiscuss the concept of .pdfModule 02 Discussion - Domestic ContainmentDiscuss the concept of .pdf
Module 02 Discussion - Domestic ContainmentDiscuss the concept of .pdf
pristiegee
 
How to do problem 15.16 Find a function f R rightarrow R^+ that i.pdf
How to do problem 15.16  Find a function f R rightarrow R^+ that i.pdfHow to do problem 15.16  Find a function f R rightarrow R^+ that i.pdf
How to do problem 15.16 Find a function f R rightarrow R^+ that i.pdf
pristiegee
 
Fill in the table below for the molecules shown. HCI Ar (atom) Ethane.pdf
Fill in the table below for the molecules shown. HCI Ar (atom) Ethane.pdfFill in the table below for the molecules shown. HCI Ar (atom) Ethane.pdf
Fill in the table below for the molecules shown. HCI Ar (atom) Ethane.pdf
pristiegee
 
How financial reporting for public companies has changed since the E.pdf
How financial reporting for public companies has changed since the E.pdfHow financial reporting for public companies has changed since the E.pdf
How financial reporting for public companies has changed since the E.pdf
pristiegee
 
Hello everyone,Im working on my fast food order project program..pdf
Hello everyone,Im working on my fast food order project program..pdfHello everyone,Im working on my fast food order project program..pdf
Hello everyone,Im working on my fast food order project program..pdf
pristiegee
 
Give the examples of network core devices Give the examples of physic.pdf
Give the examples of network core devices Give the examples of physic.pdfGive the examples of network core devices Give the examples of physic.pdf
Give the examples of network core devices Give the examples of physic.pdf
pristiegee
 
For a binary search tree that has a Node with three elements, data, a.pdf
For a binary search tree that has a Node with three elements, data, a.pdfFor a binary search tree that has a Node with three elements, data, a.pdf
For a binary search tree that has a Node with three elements, data, a.pdf
pristiegee
 
Find the coordinates of the midpoint of the segment connecting points.pdf
Find the coordinates of the midpoint of the segment connecting points.pdfFind the coordinates of the midpoint of the segment connecting points.pdf
Find the coordinates of the midpoint of the segment connecting points.pdf
pristiegee
 
Each student is to prepare a 3-5 page paper on a project on ONE of t.pdf
Each student is to prepare a 3-5 page paper on a project on ONE of t.pdfEach student is to prepare a 3-5 page paper on a project on ONE of t.pdf
Each student is to prepare a 3-5 page paper on a project on ONE of t.pdf
pristiegee
 
describe two processes by which evolution can occur. explain why.pdf
describe two processes by which evolution can occur. explain why.pdfdescribe two processes by which evolution can occur. explain why.pdf
describe two processes by which evolution can occur. explain why.pdf
pristiegee
 
Develop a structure chart for student asking diploma in university a.pdf
Develop a structure chart for student asking diploma in university a.pdfDevelop a structure chart for student asking diploma in university a.pdf
Develop a structure chart for student asking diploma in university a.pdf
pristiegee
 
Consider the following model of a very simple economy. Household savi.pdf
Consider the following model of a very simple economy. Household savi.pdfConsider the following model of a very simple economy. Household savi.pdf
Consider the following model of a very simple economy. Household savi.pdf
pristiegee
 
Assembly ProgramngCan the upper 16 bits of the four 32 bit general.pdf
Assembly ProgramngCan the upper 16 bits of the four 32 bit general.pdfAssembly ProgramngCan the upper 16 bits of the four 32 bit general.pdf
Assembly ProgramngCan the upper 16 bits of the four 32 bit general.pdf
pristiegee
 
A) How does the ability of the ligand to cross the plasma membrane d.pdf
A) How does the ability of the ligand to cross the plasma membrane d.pdfA) How does the ability of the ligand to cross the plasma membrane d.pdf
A) How does the ability of the ligand to cross the plasma membrane d.pdf
pristiegee
 

More from pristiegee (20)

Question No. 2 Describe how the Packet-Filtering Router filter data..pdf
Question No. 2 Describe how the Packet-Filtering Router filter data..pdfQuestion No. 2 Describe how the Packet-Filtering Router filter data..pdf
Question No. 2 Describe how the Packet-Filtering Router filter data..pdf
 
Indicicate the coordinaiton number of the metal and oxidation number.pdf
Indicicate the coordinaiton number of the metal and oxidation number.pdfIndicicate the coordinaiton number of the metal and oxidation number.pdf
Indicicate the coordinaiton number of the metal and oxidation number.pdf
 
QUESTION 12 12. An example of an error of presentation would be e.pdf
QUESTION 12 12. An example of an error of presentation would be e.pdfQUESTION 12 12. An example of an error of presentation would be e.pdf
QUESTION 12 12. An example of an error of presentation would be e.pdf
 
Please need help on C++ language.Infix to Postfix) Write a program.pdf
Please need help on C++ language.Infix to Postfix) Write a program.pdfPlease need help on C++ language.Infix to Postfix) Write a program.pdf
Please need help on C++ language.Infix to Postfix) Write a program.pdf
 
On a Metabolic Pathways experiment, Describe your observations below.pdf
On a Metabolic Pathways experiment, Describe your observations below.pdfOn a Metabolic Pathways experiment, Describe your observations below.pdf
On a Metabolic Pathways experiment, Describe your observations below.pdf
 
Name at least three major contributions of Islamic mathematicians..pdf
Name at least three major contributions of Islamic mathematicians..pdfName at least three major contributions of Islamic mathematicians..pdf
Name at least three major contributions of Islamic mathematicians..pdf
 
Module 02 Discussion - Domestic ContainmentDiscuss the concept of .pdf
Module 02 Discussion - Domestic ContainmentDiscuss the concept of .pdfModule 02 Discussion - Domestic ContainmentDiscuss the concept of .pdf
Module 02 Discussion - Domestic ContainmentDiscuss the concept of .pdf
 
How to do problem 15.16 Find a function f R rightarrow R^+ that i.pdf
How to do problem 15.16  Find a function f R rightarrow R^+ that i.pdfHow to do problem 15.16  Find a function f R rightarrow R^+ that i.pdf
How to do problem 15.16 Find a function f R rightarrow R^+ that i.pdf
 
Fill in the table below for the molecules shown. HCI Ar (atom) Ethane.pdf
Fill in the table below for the molecules shown. HCI Ar (atom) Ethane.pdfFill in the table below for the molecules shown. HCI Ar (atom) Ethane.pdf
Fill in the table below for the molecules shown. HCI Ar (atom) Ethane.pdf
 
How financial reporting for public companies has changed since the E.pdf
How financial reporting for public companies has changed since the E.pdfHow financial reporting for public companies has changed since the E.pdf
How financial reporting for public companies has changed since the E.pdf
 
Hello everyone,Im working on my fast food order project program..pdf
Hello everyone,Im working on my fast food order project program..pdfHello everyone,Im working on my fast food order project program..pdf
Hello everyone,Im working on my fast food order project program..pdf
 
Give the examples of network core devices Give the examples of physic.pdf
Give the examples of network core devices Give the examples of physic.pdfGive the examples of network core devices Give the examples of physic.pdf
Give the examples of network core devices Give the examples of physic.pdf
 
For a binary search tree that has a Node with three elements, data, a.pdf
For a binary search tree that has a Node with three elements, data, a.pdfFor a binary search tree that has a Node with three elements, data, a.pdf
For a binary search tree that has a Node with three elements, data, a.pdf
 
Find the coordinates of the midpoint of the segment connecting points.pdf
Find the coordinates of the midpoint of the segment connecting points.pdfFind the coordinates of the midpoint of the segment connecting points.pdf
Find the coordinates of the midpoint of the segment connecting points.pdf
 
Each student is to prepare a 3-5 page paper on a project on ONE of t.pdf
Each student is to prepare a 3-5 page paper on a project on ONE of t.pdfEach student is to prepare a 3-5 page paper on a project on ONE of t.pdf
Each student is to prepare a 3-5 page paper on a project on ONE of t.pdf
 
describe two processes by which evolution can occur. explain why.pdf
describe two processes by which evolution can occur. explain why.pdfdescribe two processes by which evolution can occur. explain why.pdf
describe two processes by which evolution can occur. explain why.pdf
 
Develop a structure chart for student asking diploma in university a.pdf
Develop a structure chart for student asking diploma in university a.pdfDevelop a structure chart for student asking diploma in university a.pdf
Develop a structure chart for student asking diploma in university a.pdf
 
Consider the following model of a very simple economy. Household savi.pdf
Consider the following model of a very simple economy. Household savi.pdfConsider the following model of a very simple economy. Household savi.pdf
Consider the following model of a very simple economy. Household savi.pdf
 
Assembly ProgramngCan the upper 16 bits of the four 32 bit general.pdf
Assembly ProgramngCan the upper 16 bits of the four 32 bit general.pdfAssembly ProgramngCan the upper 16 bits of the four 32 bit general.pdf
Assembly ProgramngCan the upper 16 bits of the four 32 bit general.pdf
 
A) How does the ability of the ligand to cross the plasma membrane d.pdf
A) How does the ability of the ligand to cross the plasma membrane d.pdfA) How does the ability of the ligand to cross the plasma membrane d.pdf
A) How does the ability of the ligand to cross the plasma membrane d.pdf
 

Recently uploaded

A Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptxA Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptx
thanhdowork
 
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
Nguyen Thanh Tu Collection
 
How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17
Celine George
 
Introduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp NetworkIntroduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp Network
TechSoup
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
Pavel ( NSTU)
 
Digital Artifact 2 - Investigating Pavilion Designs
Digital Artifact 2 - Investigating Pavilion DesignsDigital Artifact 2 - Investigating Pavilion Designs
Digital Artifact 2 - Investigating Pavilion Designs
chanes7
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
MysoreMuleSoftMeetup
 
Digital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and ResearchDigital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and Research
Vikramjit Singh
 
Chapter -12, Antibiotics (One Page Notes).pdf
Chapter -12, Antibiotics (One Page Notes).pdfChapter -12, Antibiotics (One Page Notes).pdf
Chapter -12, Antibiotics (One Page Notes).pdf
Kartik Tiwari
 
A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
Peter Windle
 
Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.
Ashokrao Mane college of Pharmacy Peth-Vadgaon
 
"Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe..."Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe...
SACHIN R KONDAGURI
 
Pride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School DistrictPride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School District
David Douglas School District
 
The approach at University of Liverpool.pptx
The approach at University of Liverpool.pptxThe approach at University of Liverpool.pptx
The approach at University of Liverpool.pptx
Jisc
 
CACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdfCACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdf
camakaiclarkmusic
 
How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...
Jisc
 
Embracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic ImperativeEmbracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic Imperative
Peter Windle
 
The French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free downloadThe French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free download
Vivekanand Anglo Vedic Academy
 
Marketing internship report file for MBA
Marketing internship report file for MBAMarketing internship report file for MBA
Marketing internship report file for MBA
gb193092
 
Normal Labour/ Stages of Labour/ Mechanism of Labour
Normal Labour/ Stages of Labour/ Mechanism of LabourNormal Labour/ Stages of Labour/ Mechanism of Labour
Normal Labour/ Stages of Labour/ Mechanism of Labour
Wasim Ak
 

Recently uploaded (20)

A Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptxA Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptx
 
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
 
How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17
 
Introduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp NetworkIntroduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp Network
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
 
Digital Artifact 2 - Investigating Pavilion Designs
Digital Artifact 2 - Investigating Pavilion DesignsDigital Artifact 2 - Investigating Pavilion Designs
Digital Artifact 2 - Investigating Pavilion Designs
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
 
Digital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and ResearchDigital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and Research
 
Chapter -12, Antibiotics (One Page Notes).pdf
Chapter -12, Antibiotics (One Page Notes).pdfChapter -12, Antibiotics (One Page Notes).pdf
Chapter -12, Antibiotics (One Page Notes).pdf
 
A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
 
Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.
 
"Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe..."Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe...
 
Pride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School DistrictPride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School District
 
The approach at University of Liverpool.pptx
The approach at University of Liverpool.pptxThe approach at University of Liverpool.pptx
The approach at University of Liverpool.pptx
 
CACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdfCACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdf
 
How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...
 
Embracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic ImperativeEmbracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic Imperative
 
The French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free downloadThe French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free download
 
Marketing internship report file for MBA
Marketing internship report file for MBAMarketing internship report file for MBA
Marketing internship report file for MBA
 
Normal Labour/ Stages of Labour/ Mechanism of Labour
Normal Labour/ Stages of Labour/ Mechanism of LabourNormal Labour/ Stages of Labour/ Mechanism of Labour
Normal Labour/ Stages of Labour/ Mechanism of Labour
 

Write a C program using fork() alone to mimic the below below observ.pdf

  • 1. Write a C program using fork() alone to mimic the below below observations. Consider the following statements: S2 S1 z 1 S3 c a b; S3 S 4 d C-1; S4 The corresponding Precedence graph is as shown above Solution In the above description we are having statements execute parallely. This is because, the system may have multiple CPUs or floating point units which compute at the same time as CPU. Problem is some statements must be completed before others begun. And to construct these type of statements we are using fork(). Fork() look like fork label and splits process into two, which is starting at the label and other is which is falling through. fork L; a:=x+y; ... L: :b=z+1; Fork() system call is used for creating Processes. It returns process ID. It creates new process which is the child process of the caller. Along with Fork() we can use parallel construct Join(). Join() merges processes and has count label. Count will zero if there is a branch at label. count :=count - 1; if count =0 then goto label; Now for above precedence graph, code will be as below: count=2; fork dopar; a:= x+y; goto donepar; dopar: b:=z+1 donepar: join count, cont; quit; cont: c:=a+b; d:=c-1; Strengths using fork() system call is, simple, powerful, easy to derive from precedence graphs.