SlideShare a Scribd company logo
System Call
Fork()
Fork()
▪ Defination:
▪ In computing, the fork is an operation whereby a process creates a copy of itself.
▪ it is usually called a system call, implemented in the Kennel.
▪ Simply We can say that fork is the Primary method of process Creation
▪ It takes no arguments and returns a process ID
Overview
▪ In multitasking operating systems, processes (running programs) need a way to
create new processes, to run other programs.
▪ In Unix systems equipped with virtual memory support (practically all modern
variants), the fork operation creates a separate address space for the child. The
child process has an exact copy of all the memory segments of the parent
process.
Purpose of fork()
▪ The purpose of fork() is to create a new process, which becomes
the child process of the caller. After a new child process is
created, both processes will execute the next instruction following
the fork() system call.
▪ Unix will make an exact copy of the parent's address space and give it to
the child. Therefore, the parent and child processes have separate address
spaces.
A=1
B=2
Example of Fork ()
Process
A=1
B=2
Parent
Child
A=7
B=5
A=1
B=2
Exit
Change the
Child
Process
value
One Process Not effect the
other Process
If Child Process Return
nothing
A Process executes the code
Fork()
Fork()
Fork()
The total number of the child process created is
(A) 3 (B) 4 (C) 7 (D) 8
Example of Fork ()
Example of Fork () Main Process
Child Process
1.Fork ()
2.Fork ()
3.Fork ()
1 2 3 4 5 6 7 8
Answer is 7
System Call
“exec” family
exec()
In computing, exec is a functionality of an operating
system that runs an executable file in the context of an
already existing process, replacing the previous
executable.
Why “exec” functionality ?
▪ Is fork enough to create a new process with
different code and data segment in the same
process id ?
 Forking creates a process but it is not enough to run a
new program, to do that the forked child needs to overwrite
its own image with the code and data of the new program
and mechanism is exec() creation.
When “exec()” call ?
▪ No new process create.
▪ Replace the data segment and code segment of current process.
▪ Process ID remain same.
▪ Calling process data and code is gone .
▪ Cannot return to the caller .
How exec work ?
int main(){
doWorkOne();
call B.exe via exec
doWorkTwo();
return 0;
}
int main(){
doWorkOne();
call B.exe via exec…..
doWorkTwo(); ××
return 0;
}
A.cpp / A.exe
int main(){
doWorkThree();
return 0
}
B.cpp / B.exe
int main(){
doWorkThree();
return 0;
}
C language prototypes
int execl(char const *path, char const *arg0, ...);
int execle(char const *path, char const *arg0, ..., char const *envp[]);
int execlp(char const *file, char const *arg0, ...);
int execv(char const *path, char const *argv[]);
int execve(char const *path, char const *argv[], char const *envp[]);
int execvp(char const *file, char const *argv[]);
 “ l ” is specified as a list of arguments.
 “ v “ is specified as a vector (array of character pointers).
“ e “ environment is specified as an array of character pointers.
“ p “ user's PATH is searched for command, and command can be a shell program
If exec return value<0 then Error occurred in “exec” call .
Else successfully call the “exec”
Applications
• If any program need run a new process in the same context
(i.e : open a program from another program).
• Continuously run new process from child process (i.e : Terminal ).
Thank You….

More Related Content

What's hot

What's hot (20)

Os Threads
Os ThreadsOs Threads
Os Threads
 
Semaphores
SemaphoresSemaphores
Semaphores
 
Os unit 3 , process management
Os unit 3 , process managementOs unit 3 , process management
Os unit 3 , process management
 
Memory Management in OS
Memory Management in OSMemory Management in OS
Memory Management in OS
 
Process threads operating system.
Process threads operating system.Process threads operating system.
Process threads operating system.
 
Semaphores OS Basics
Semaphores OS BasicsSemaphores OS Basics
Semaphores OS Basics
 
Shell and its types in LINUX
Shell and its types in LINUXShell and its types in LINUX
Shell and its types in LINUX
 
Threads (operating System)
Threads (operating System)Threads (operating System)
Threads (operating System)
 
Deadlock ppt
Deadlock ppt Deadlock ppt
Deadlock ppt
 
Process synchronization
Process synchronizationProcess synchronization
Process synchronization
 
CPU Scheduling Algorithms
CPU Scheduling AlgorithmsCPU Scheduling Algorithms
CPU Scheduling Algorithms
 
Deadlock
DeadlockDeadlock
Deadlock
 
Presentation on Segmentation
Presentation on SegmentationPresentation on Segmentation
Presentation on Segmentation
 
Input output streams
Input output streamsInput output streams
Input output streams
 
cpu scheduling
cpu schedulingcpu scheduling
cpu scheduling
 
Deadlocks in operating system
Deadlocks in operating systemDeadlocks in operating system
Deadlocks in operating system
 
Inter Process Communication
Inter Process CommunicationInter Process Communication
Inter Process Communication
 
Process management os concept
Process management os conceptProcess management os concept
Process management os concept
 
SCHEDULING ALGORITHMS
SCHEDULING ALGORITHMSSCHEDULING ALGORITHMS
SCHEDULING ALGORITHMS
 
Mca ii os u-1 introduction to os
Mca  ii  os u-1 introduction to osMca  ii  os u-1 introduction to os
Mca ii os u-1 introduction to os
 

Viewers also liked

Viewers also liked (16)

Introduction to System Calls
Introduction to System CallsIntroduction to System Calls
Introduction to System Calls
 
Lesson 10 Application Program Interface
Lesson 10 Application Program InterfaceLesson 10 Application Program Interface
Lesson 10 Application Program Interface
 
Unix system calls
Unix system callsUnix system calls
Unix system calls
 
Operating Systems 1 (6/12) - Processes
Operating Systems 1 (6/12) - ProcessesOperating Systems 1 (6/12) - Processes
Operating Systems 1 (6/12) - Processes
 
System Calls
System CallsSystem Calls
System Calls
 
System calls
System callsSystem calls
System calls
 
Part 04 Creating a System Call in Linux
Part 04 Creating a System Call in LinuxPart 04 Creating a System Call in Linux
Part 04 Creating a System Call in Linux
 
Linux Programming
Linux ProgrammingLinux Programming
Linux Programming
 
Processes in unix
Processes in unixProcesses in unix
Processes in unix
 
What is Kernel, basic idea of kernel
What is Kernel, basic idea of kernelWhat is Kernel, basic idea of kernel
What is Kernel, basic idea of kernel
 
Unix Process management
Unix Process managementUnix Process management
Unix Process management
 
Kernel mode vs user mode in linux
Kernel mode vs user mode in linuxKernel mode vs user mode in linux
Kernel mode vs user mode in linux
 
Kernel (OS)
Kernel (OS)Kernel (OS)
Kernel (OS)
 
Unix system programming
Unix system programmingUnix system programming
Unix system programming
 
Unix operating system
Unix operating systemUnix operating system
Unix operating system
 
8. mutual exclusion in Distributed Operating Systems
8. mutual exclusion in Distributed Operating Systems8. mutual exclusion in Distributed Operating Systems
8. mutual exclusion in Distributed Operating Systems
 

Similar to System call (Fork +Exec)

OS presentation (1).pptx
OS presentation (1).pptxOS presentation (1).pptx
OS presentation (1).pptxJenish62
 
computer notes - Inter process communication
computer notes - Inter process communicationcomputer notes - Inter process communication
computer notes - Inter process communicationecomputernotes
 
11_UNIX_Processes_Including_Select.ppt
11_UNIX_Processes_Including_Select.ppt11_UNIX_Processes_Including_Select.ppt
11_UNIX_Processes_Including_Select.pptSIDDHARTHANANDCSE202
 
What is-a-computer-process-os
What is-a-computer-process-osWhat is-a-computer-process-os
What is-a-computer-process-osManish Singh
 
CorePy High-Productivity CellB.E. Programming
CorePy High-Productivity CellB.E. ProgrammingCorePy High-Productivity CellB.E. Programming
CorePy High-Productivity CellB.E. ProgrammingSlide_N
 
DEF CON 27 - KYLE GWINNUP - next generation process emulation with binee
DEF CON 27 - KYLE GWINNUP - next generation process emulation with bineeDEF CON 27 - KYLE GWINNUP - next generation process emulation with binee
DEF CON 27 - KYLE GWINNUP - next generation process emulation with bineeFelipe Prado
 
Program Assignment Process ManagementObjective This program a.docx
Program Assignment  Process ManagementObjective This program a.docxProgram Assignment  Process ManagementObjective This program a.docx
Program Assignment Process ManagementObjective This program a.docxwkyra78
 
Parallel Programming With Dot Net
Parallel Programming With Dot NetParallel Programming With Dot Net
Parallel Programming With Dot NetNeeraj Kaushik
 
System Calls.pptxnsjsnssbhsbbebdbdbshshsbshsbbs
System Calls.pptxnsjsnssbhsbbebdbdbshshsbshsbbsSystem Calls.pptxnsjsnssbhsbbebdbdbshshsbshsbbs
System Calls.pptxnsjsnssbhsbbebdbdbshshsbshsbbsashukiller7
 
Boo Manifesto
Boo ManifestoBoo Manifesto
Boo Manifestohu hans
 
Lecture_Slide_4.pptx
Lecture_Slide_4.pptxLecture_Slide_4.pptx
Lecture_Slide_4.pptxDiptoRoy21
 
04_ForkPipe.pptx
04_ForkPipe.pptx04_ForkPipe.pptx
04_ForkPipe.pptxvnwzympx
 
Linux Systems Programming: Process CommunCh11 Processes and Signals
Linux Systems Programming: Process CommunCh11 Processes and SignalsLinux Systems Programming: Process CommunCh11 Processes and Signals
Linux Systems Programming: Process CommunCh11 Processes and SignalsRashidFaridChishti
 
EKON 25 Python4Delphi_mX4
EKON 25 Python4Delphi_mX4EKON 25 Python4Delphi_mX4
EKON 25 Python4Delphi_mX4Max Kleiner
 
Jdk 7 4-forkjoin
Jdk 7 4-forkjoinJdk 7 4-forkjoin
Jdk 7 4-forkjoinknight1128
 
History of asynchronous in .NET
History of asynchronous in .NETHistory of asynchronous in .NET
History of asynchronous in .NETMarcin Tyborowski
 

Similar to System call (Fork +Exec) (20)

OS presentation (1).pptx
OS presentation (1).pptxOS presentation (1).pptx
OS presentation (1).pptx
 
computer notes - Inter process communication
computer notes - Inter process communicationcomputer notes - Inter process communication
computer notes - Inter process communication
 
Os lab final
Os lab finalOs lab final
Os lab final
 
11_UNIX_Processes_Including_Select.ppt
11_UNIX_Processes_Including_Select.ppt11_UNIX_Processes_Including_Select.ppt
11_UNIX_Processes_Including_Select.ppt
 
What is-a-computer-process-os
What is-a-computer-process-osWhat is-a-computer-process-os
What is-a-computer-process-os
 
CorePy High-Productivity CellB.E. Programming
CorePy High-Productivity CellB.E. ProgrammingCorePy High-Productivity CellB.E. Programming
CorePy High-Productivity CellB.E. Programming
 
Computer Science Assignment Help
Computer Science Assignment HelpComputer Science Assignment Help
Computer Science Assignment Help
 
DEF CON 27 - KYLE GWINNUP - next generation process emulation with binee
DEF CON 27 - KYLE GWINNUP - next generation process emulation with bineeDEF CON 27 - KYLE GWINNUP - next generation process emulation with binee
DEF CON 27 - KYLE GWINNUP - next generation process emulation with binee
 
Program Assignment Process ManagementObjective This program a.docx
Program Assignment  Process ManagementObjective This program a.docxProgram Assignment  Process ManagementObjective This program a.docx
Program Assignment Process ManagementObjective This program a.docx
 
Parallel Programming With Dot Net
Parallel Programming With Dot NetParallel Programming With Dot Net
Parallel Programming With Dot Net
 
System Calls.pptxnsjsnssbhsbbebdbdbshshsbshsbbs
System Calls.pptxnsjsnssbhsbbebdbdbshshsbshsbbsSystem Calls.pptxnsjsnssbhsbbebdbdbshshsbshsbbs
System Calls.pptxnsjsnssbhsbbebdbdbshshsbshsbbs
 
Boo Manifesto
Boo ManifestoBoo Manifesto
Boo Manifesto
 
Lecture_Slide_4.pptx
Lecture_Slide_4.pptxLecture_Slide_4.pptx
Lecture_Slide_4.pptx
 
Activity 5
Activity 5Activity 5
Activity 5
 
04_ForkPipe.pptx
04_ForkPipe.pptx04_ForkPipe.pptx
04_ForkPipe.pptx
 
Lect3 process
Lect3 processLect3 process
Lect3 process
 
Linux Systems Programming: Process CommunCh11 Processes and Signals
Linux Systems Programming: Process CommunCh11 Processes and SignalsLinux Systems Programming: Process CommunCh11 Processes and Signals
Linux Systems Programming: Process CommunCh11 Processes and Signals
 
EKON 25 Python4Delphi_mX4
EKON 25 Python4Delphi_mX4EKON 25 Python4Delphi_mX4
EKON 25 Python4Delphi_mX4
 
Jdk 7 4-forkjoin
Jdk 7 4-forkjoinJdk 7 4-forkjoin
Jdk 7 4-forkjoin
 
History of asynchronous in .NET
History of asynchronous in .NETHistory of asynchronous in .NET
History of asynchronous in .NET
 

More from Amit Ghosh

Custom object detection using Deep Learning
Custom object detection using Deep Learning Custom object detection using Deep Learning
Custom object detection using Deep Learning Amit Ghosh
 
Data Set Analysis
Data Set Analysis Data Set Analysis
Data Set Analysis Amit Ghosh
 
Cloud platform comparison
Cloud platform comparison Cloud platform comparison
Cloud platform comparison Amit Ghosh
 
Gitlab runner in aws
Gitlab runner in aws Gitlab runner in aws
Gitlab runner in aws Amit Ghosh
 
MongoDB Aggregation
MongoDB Aggregation MongoDB Aggregation
MongoDB Aggregation Amit Ghosh
 
Restaurant ordering system
Restaurant ordering systemRestaurant ordering system
Restaurant ordering systemAmit Ghosh
 
System Analysis And Development Course
System Analysis And Development Course System Analysis And Development Course
System Analysis And Development Course Amit Ghosh
 
Convex hull presentation
Convex hull presentation Convex hull presentation
Convex hull presentation Amit Ghosh
 
Smart City Hackathon Presentation
Smart City Hackathon PresentationSmart City Hackathon Presentation
Smart City Hackathon PresentationAmit Ghosh
 
Pattern presentation
Pattern presentationPattern presentation
Pattern presentationAmit Ghosh
 
Shell & Shell Script
Shell & Shell ScriptShell & Shell Script
Shell & Shell ScriptAmit Ghosh
 
Shell & Shell Script
Shell & Shell Script Shell & Shell Script
Shell & Shell Script Amit Ghosh
 

More from Amit Ghosh (13)

Custom object detection using Deep Learning
Custom object detection using Deep Learning Custom object detection using Deep Learning
Custom object detection using Deep Learning
 
Data Set Analysis
Data Set Analysis Data Set Analysis
Data Set Analysis
 
Cloud platform comparison
Cloud platform comparison Cloud platform comparison
Cloud platform comparison
 
Gitlab runner in aws
Gitlab runner in aws Gitlab runner in aws
Gitlab runner in aws
 
MongoDB Aggregation
MongoDB Aggregation MongoDB Aggregation
MongoDB Aggregation
 
Restaurant ordering system
Restaurant ordering systemRestaurant ordering system
Restaurant ordering system
 
System Analysis And Development Course
System Analysis And Development Course System Analysis And Development Course
System Analysis And Development Course
 
Bumble bee
Bumble beeBumble bee
Bumble bee
 
Convex hull presentation
Convex hull presentation Convex hull presentation
Convex hull presentation
 
Smart City Hackathon Presentation
Smart City Hackathon PresentationSmart City Hackathon Presentation
Smart City Hackathon Presentation
 
Pattern presentation
Pattern presentationPattern presentation
Pattern presentation
 
Shell & Shell Script
Shell & Shell ScriptShell & Shell Script
Shell & Shell Script
 
Shell & Shell Script
Shell & Shell Script Shell & Shell Script
Shell & Shell Script
 

Recently uploaded

slides CapTechTalks Webinar May 2024 Alexander Perry.pptx
slides CapTechTalks Webinar May 2024 Alexander Perry.pptxslides CapTechTalks Webinar May 2024 Alexander Perry.pptx
slides CapTechTalks Webinar May 2024 Alexander Perry.pptxCapitolTechU
 
size separation d pharm 1st year pharmaceutics
size separation d pharm 1st year pharmaceuticssize separation d pharm 1st year pharmaceutics
size separation d pharm 1st year pharmaceuticspragatimahajan3
 
Basic Civil Engineering Notes of Chapter-6, Topic- Ecosystem, Biodiversity G...
Basic Civil Engineering Notes of Chapter-6,  Topic- Ecosystem, Biodiversity G...Basic Civil Engineering Notes of Chapter-6,  Topic- Ecosystem, Biodiversity G...
Basic Civil Engineering Notes of Chapter-6, Topic- Ecosystem, Biodiversity G...Denish Jangid
 
Telling Your Story_ Simple Steps to Build Your Nonprofit's Brand Webinar.pdf
Telling Your Story_ Simple Steps to Build Your Nonprofit's Brand Webinar.pdfTelling Your Story_ Simple Steps to Build Your Nonprofit's Brand Webinar.pdf
Telling Your Story_ Simple Steps to Build Your Nonprofit's Brand Webinar.pdfTechSoup
 
MARUTI SUZUKI- A Successful Joint Venture in India.pptx
MARUTI SUZUKI- A Successful Joint Venture in India.pptxMARUTI SUZUKI- A Successful Joint Venture in India.pptx
MARUTI SUZUKI- A Successful Joint Venture in India.pptxbennyroshan06
 
INU_CAPSTONEDESIGN_비밀번호486_업로드용 발표자료.pdf
INU_CAPSTONEDESIGN_비밀번호486_업로드용 발표자료.pdfINU_CAPSTONEDESIGN_비밀번호486_업로드용 발표자료.pdf
INU_CAPSTONEDESIGN_비밀번호486_업로드용 발표자료.pdfbu07226
 
How to Break the cycle of negative Thoughts
How to Break the cycle of negative ThoughtsHow to Break the cycle of negative Thoughts
How to Break the cycle of negative ThoughtsCol Mukteshwar Prasad
 
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...Nguyen Thanh Tu Collection
 
Gyanartha SciBizTech Quiz slideshare.pptx
Gyanartha SciBizTech Quiz slideshare.pptxGyanartha SciBizTech Quiz slideshare.pptx
Gyanartha SciBizTech Quiz slideshare.pptxShibin Azad
 
Basic_QTL_Marker-assisted_Selection_Sourabh.ppt
Basic_QTL_Marker-assisted_Selection_Sourabh.pptBasic_QTL_Marker-assisted_Selection_Sourabh.ppt
Basic_QTL_Marker-assisted_Selection_Sourabh.pptSourabh Kumar
 
The Benefits and Challenges of Open Educational Resources
The Benefits and Challenges of Open Educational ResourcesThe Benefits and Challenges of Open Educational Resources
The Benefits and Challenges of Open Educational Resourcesaileywriter
 
Basic phrases for greeting and assisting costumers
Basic phrases for greeting and assisting costumersBasic phrases for greeting and assisting costumers
Basic phrases for greeting and assisting costumersPedroFerreira53928
 
Additional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdfAdditional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdfjoachimlavalley1
 
Keeping Your Information Safe with Centralized Security Services
Keeping Your Information Safe with Centralized Security ServicesKeeping Your Information Safe with Centralized Security Services
Keeping Your Information Safe with Centralized Security ServicesTechSoup
 
Morse OER Some Benefits and Challenges.pptx
Morse OER Some Benefits and Challenges.pptxMorse OER Some Benefits and Challenges.pptx
Morse OER Some Benefits and Challenges.pptxjmorse8
 
How to Manage Notification Preferences in the Odoo 17
How to Manage Notification Preferences in the Odoo 17How to Manage Notification Preferences in the Odoo 17
How to Manage Notification Preferences in the Odoo 17Celine George
 
Benefits and Challenges of Using Open Educational Resources
Benefits and Challenges of Using Open Educational ResourcesBenefits and Challenges of Using Open Educational Resources
Benefits and Challenges of Using Open Educational Resourcesdimpy50
 

Recently uploaded (20)

slides CapTechTalks Webinar May 2024 Alexander Perry.pptx
slides CapTechTalks Webinar May 2024 Alexander Perry.pptxslides CapTechTalks Webinar May 2024 Alexander Perry.pptx
slides CapTechTalks Webinar May 2024 Alexander Perry.pptx
 
size separation d pharm 1st year pharmaceutics
size separation d pharm 1st year pharmaceuticssize separation d pharm 1st year pharmaceutics
size separation d pharm 1st year pharmaceutics
 
Basic Civil Engineering Notes of Chapter-6, Topic- Ecosystem, Biodiversity G...
Basic Civil Engineering Notes of Chapter-6,  Topic- Ecosystem, Biodiversity G...Basic Civil Engineering Notes of Chapter-6,  Topic- Ecosystem, Biodiversity G...
Basic Civil Engineering Notes of Chapter-6, Topic- Ecosystem, Biodiversity G...
 
Mattingly "AI & Prompt Design: Limitations and Solutions with LLMs"
Mattingly "AI & Prompt Design: Limitations and Solutions with LLMs"Mattingly "AI & Prompt Design: Limitations and Solutions with LLMs"
Mattingly "AI & Prompt Design: Limitations and Solutions with LLMs"
 
Telling Your Story_ Simple Steps to Build Your Nonprofit's Brand Webinar.pdf
Telling Your Story_ Simple Steps to Build Your Nonprofit's Brand Webinar.pdfTelling Your Story_ Simple Steps to Build Your Nonprofit's Brand Webinar.pdf
Telling Your Story_ Simple Steps to Build Your Nonprofit's Brand Webinar.pdf
 
MARUTI SUZUKI- A Successful Joint Venture in India.pptx
MARUTI SUZUKI- A Successful Joint Venture in India.pptxMARUTI SUZUKI- A Successful Joint Venture in India.pptx
MARUTI SUZUKI- A Successful Joint Venture in India.pptx
 
INU_CAPSTONEDESIGN_비밀번호486_업로드용 발표자료.pdf
INU_CAPSTONEDESIGN_비밀번호486_업로드용 발표자료.pdfINU_CAPSTONEDESIGN_비밀번호486_업로드용 발표자료.pdf
INU_CAPSTONEDESIGN_비밀번호486_업로드용 발표자료.pdf
 
How to Break the cycle of negative Thoughts
How to Break the cycle of negative ThoughtsHow to Break the cycle of negative Thoughts
How to Break the cycle of negative Thoughts
 
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
 
Gyanartha SciBizTech Quiz slideshare.pptx
Gyanartha SciBizTech Quiz slideshare.pptxGyanartha SciBizTech Quiz slideshare.pptx
Gyanartha SciBizTech Quiz slideshare.pptx
 
Basic_QTL_Marker-assisted_Selection_Sourabh.ppt
Basic_QTL_Marker-assisted_Selection_Sourabh.pptBasic_QTL_Marker-assisted_Selection_Sourabh.ppt
Basic_QTL_Marker-assisted_Selection_Sourabh.ppt
 
Operations Management - Book1.p - Dr. Abdulfatah A. Salem
Operations Management - Book1.p  - Dr. Abdulfatah A. SalemOperations Management - Book1.p  - Dr. Abdulfatah A. Salem
Operations Management - Book1.p - Dr. Abdulfatah A. Salem
 
The Benefits and Challenges of Open Educational Resources
The Benefits and Challenges of Open Educational ResourcesThe Benefits and Challenges of Open Educational Resources
The Benefits and Challenges of Open Educational Resources
 
Basic phrases for greeting and assisting costumers
Basic phrases for greeting and assisting costumersBasic phrases for greeting and assisting costumers
Basic phrases for greeting and assisting costumers
 
Additional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdfAdditional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdf
 
Keeping Your Information Safe with Centralized Security Services
Keeping Your Information Safe with Centralized Security ServicesKeeping Your Information Safe with Centralized Security Services
Keeping Your Information Safe with Centralized Security Services
 
Morse OER Some Benefits and Challenges.pptx
Morse OER Some Benefits and Challenges.pptxMorse OER Some Benefits and Challenges.pptx
Morse OER Some Benefits and Challenges.pptx
 
B.ed spl. HI pdusu exam paper-2023-24.pdf
B.ed spl. HI pdusu exam paper-2023-24.pdfB.ed spl. HI pdusu exam paper-2023-24.pdf
B.ed spl. HI pdusu exam paper-2023-24.pdf
 
How to Manage Notification Preferences in the Odoo 17
How to Manage Notification Preferences in the Odoo 17How to Manage Notification Preferences in the Odoo 17
How to Manage Notification Preferences in the Odoo 17
 
Benefits and Challenges of Using Open Educational Resources
Benefits and Challenges of Using Open Educational ResourcesBenefits and Challenges of Using Open Educational Resources
Benefits and Challenges of Using Open Educational Resources
 

System call (Fork +Exec)

  • 2. Fork() ▪ Defination: ▪ In computing, the fork is an operation whereby a process creates a copy of itself. ▪ it is usually called a system call, implemented in the Kennel. ▪ Simply We can say that fork is the Primary method of process Creation ▪ It takes no arguments and returns a process ID
  • 3. Overview ▪ In multitasking operating systems, processes (running programs) need a way to create new processes, to run other programs. ▪ In Unix systems equipped with virtual memory support (practically all modern variants), the fork operation creates a separate address space for the child. The child process has an exact copy of all the memory segments of the parent process.
  • 4. Purpose of fork() ▪ The purpose of fork() is to create a new process, which becomes the child process of the caller. After a new child process is created, both processes will execute the next instruction following the fork() system call. ▪ Unix will make an exact copy of the parent's address space and give it to the child. Therefore, the parent and child processes have separate address spaces.
  • 5. A=1 B=2 Example of Fork () Process A=1 B=2 Parent Child A=7 B=5 A=1 B=2 Exit Change the Child Process value
  • 6. One Process Not effect the other Process If Child Process Return nothing
  • 7. A Process executes the code Fork() Fork() Fork() The total number of the child process created is (A) 3 (B) 4 (C) 7 (D) 8 Example of Fork ()
  • 8. Example of Fork () Main Process Child Process 1.Fork () 2.Fork () 3.Fork () 1 2 3 4 5 6 7 8 Answer is 7
  • 10. exec() In computing, exec is a functionality of an operating system that runs an executable file in the context of an already existing process, replacing the previous executable.
  • 11. Why “exec” functionality ? ▪ Is fork enough to create a new process with different code and data segment in the same process id ?
  • 12.  Forking creates a process but it is not enough to run a new program, to do that the forked child needs to overwrite its own image with the code and data of the new program and mechanism is exec() creation.
  • 13. When “exec()” call ? ▪ No new process create. ▪ Replace the data segment and code segment of current process. ▪ Process ID remain same. ▪ Calling process data and code is gone . ▪ Cannot return to the caller .
  • 14. How exec work ? int main(){ doWorkOne(); call B.exe via exec doWorkTwo(); return 0; } int main(){ doWorkOne(); call B.exe via exec….. doWorkTwo(); ×× return 0; } A.cpp / A.exe int main(){ doWorkThree(); return 0 } B.cpp / B.exe int main(){ doWorkThree(); return 0; }
  • 15. C language prototypes int execl(char const *path, char const *arg0, ...); int execle(char const *path, char const *arg0, ..., char const *envp[]); int execlp(char const *file, char const *arg0, ...); int execv(char const *path, char const *argv[]); int execve(char const *path, char const *argv[], char const *envp[]); int execvp(char const *file, char const *argv[]);  “ l ” is specified as a list of arguments.  “ v “ is specified as a vector (array of character pointers). “ e “ environment is specified as an array of character pointers. “ p “ user's PATH is searched for command, and command can be a shell program If exec return value<0 then Error occurred in “exec” call . Else successfully call the “exec”
  • 16. Applications • If any program need run a new process in the same context (i.e : open a program from another program). • Continuously run new process from child process (i.e : Terminal ).