SlideShare une entreprise Scribd logo
1  sur  17
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….

Contenu connexe

Tendances

Multithreading
MultithreadingMultithreading
MultithreadingA B Shinde
 
SOLUTION MANUAL OF OPERATING SYSTEM CONCEPTS BY ABRAHAM SILBERSCHATZ, PETER B...
SOLUTION MANUAL OF OPERATING SYSTEM CONCEPTS BY ABRAHAM SILBERSCHATZ, PETER B...SOLUTION MANUAL OF OPERATING SYSTEM CONCEPTS BY ABRAHAM SILBERSCHATZ, PETER B...
SOLUTION MANUAL OF OPERATING SYSTEM CONCEPTS BY ABRAHAM SILBERSCHATZ, PETER B...vtunotesbysree
 
deadlock avoidance
deadlock avoidancedeadlock avoidance
deadlock avoidancewahab13
 
distributed Computing system model
distributed Computing system modeldistributed Computing system model
distributed Computing system modelHarshad Umredkar
 
Processes in unix
Processes in unixProcesses in unix
Processes in unixmiau_max
 
Process scheduling (CPU Scheduling)
Process scheduling (CPU Scheduling)Process scheduling (CPU Scheduling)
Process scheduling (CPU Scheduling)Mukesh Chinta
 
Socket Programming
Socket ProgrammingSocket Programming
Socket ProgrammingCEC Landran
 
OS - Process Concepts
OS - Process ConceptsOS - Process Concepts
OS - Process ConceptsMukesh Chinta
 
Classical problem of synchronization
Classical problem of synchronizationClassical problem of synchronization
Classical problem of synchronizationShakshi Ranawat
 
Operating System-Ch8 memory management
Operating System-Ch8 memory managementOperating System-Ch8 memory management
Operating System-Ch8 memory managementSyaiful Ahdan
 
Process synchronization in Operating Systems
Process synchronization in Operating SystemsProcess synchronization in Operating Systems
Process synchronization in Operating SystemsRitu Ranjan Shrivastwa
 

Tendances (20)

Ipc in linux
Ipc in linuxIpc in linux
Ipc in linux
 
Semaphore
SemaphoreSemaphore
Semaphore
 
Know the UNIX Commands
Know the UNIX CommandsKnow the UNIX Commands
Know the UNIX Commands
 
Multithreading
MultithreadingMultithreading
Multithreading
 
SOLUTION MANUAL OF OPERATING SYSTEM CONCEPTS BY ABRAHAM SILBERSCHATZ, PETER B...
SOLUTION MANUAL OF OPERATING SYSTEM CONCEPTS BY ABRAHAM SILBERSCHATZ, PETER B...SOLUTION MANUAL OF OPERATING SYSTEM CONCEPTS BY ABRAHAM SILBERSCHATZ, PETER B...
SOLUTION MANUAL OF OPERATING SYSTEM CONCEPTS BY ABRAHAM SILBERSCHATZ, PETER B...
 
System call
System callSystem call
System call
 
Shell programming
Shell programmingShell programming
Shell programming
 
deadlock avoidance
deadlock avoidancedeadlock avoidance
deadlock avoidance
 
BANKER'S ALGORITHM
BANKER'S ALGORITHMBANKER'S ALGORITHM
BANKER'S ALGORITHM
 
distributed Computing system model
distributed Computing system modeldistributed Computing system model
distributed Computing system model
 
Processes in unix
Processes in unixProcesses in unix
Processes in unix
 
Process scheduling (CPU Scheduling)
Process scheduling (CPU Scheduling)Process scheduling (CPU Scheduling)
Process scheduling (CPU Scheduling)
 
Socket Programming
Socket ProgrammingSocket Programming
Socket Programming
 
SHELL PROGRAMMING
SHELL PROGRAMMINGSHELL PROGRAMMING
SHELL PROGRAMMING
 
OS - Process Concepts
OS - Process ConceptsOS - Process Concepts
OS - Process Concepts
 
Classical problem of synchronization
Classical problem of synchronizationClassical problem of synchronization
Classical problem of synchronization
 
Process state in OS
Process state in OSProcess state in OS
Process state in OS
 
Operating System-Ch8 memory management
Operating System-Ch8 memory managementOperating System-Ch8 memory management
Operating System-Ch8 memory management
 
Memory management
Memory managementMemory management
Memory management
 
Process synchronization in Operating Systems
Process synchronization in Operating SystemsProcess synchronization in Operating Systems
Process synchronization in Operating Systems
 

En vedette

Introduction to System Calls
Introduction to System CallsIntroduction to System Calls
Introduction to System CallsVandana Salve
 
Operating Systems 1 (6/12) - Processes
Operating Systems 1 (6/12) - ProcessesOperating Systems 1 (6/12) - Processes
Operating Systems 1 (6/12) - ProcessesPeter Tröger
 
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 LinuxTushar B Kute
 
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 kernelNeel Parikh
 
Unix Process management
Unix Process managementUnix Process management
Unix Process managementWave Digitech
 
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 linuxSiddique Ibrahim
 
Unix system programming
Unix system programmingUnix system programming
Unix system programmingSyed Mustafa
 
Unix operating system
Unix operating systemUnix operating system
Unix operating systemABhay Panchal
 
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 SystemsDr Sandeep Kumar Poonia
 

En vedette (15)

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
 
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
 
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
 
Semaphores
SemaphoresSemaphores
Semaphores
 
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
 
Inter Process Communication
Inter Process CommunicationInter Process Communication
Inter Process Communication
 
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
 

Similaire à 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
 
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
 

Similaire à 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
 
process creation OS
process creation OSprocess creation OS
process creation 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
 
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
 

Plus de 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
 

Plus de 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
 

Dernier

Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxVishalSingh1417
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfciinovamais
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhikauryashika82
 
Magic bus Group work1and 2 (Team 3).pptx
Magic bus Group work1and 2 (Team 3).pptxMagic bus Group work1and 2 (Team 3).pptx
Magic bus Group work1and 2 (Team 3).pptxdhanalakshmis0310
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxDenish Jangid
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdfQucHHunhnh
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.pptRamjanShidvankar
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...ZurliaSoop
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfAdmir Softic
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxheathfieldcps1
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17Celine George
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxVishalSingh1417
 
psychiatric nursing HISTORY COLLECTION .docx
psychiatric  nursing HISTORY  COLLECTION  .docxpsychiatric  nursing HISTORY  COLLECTION  .docx
psychiatric nursing HISTORY COLLECTION .docxPoojaSen20
 
Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...Association for Project Management
 
Seal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxSeal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxnegromaestrong
 
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptxMaritesTamaniVerdade
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.MaryamAhmad92
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...Poonam Aher Patil
 

Dernier (20)

Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptx
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
 
Magic bus Group work1and 2 (Team 3).pptx
Magic bus Group work1and 2 (Team 3).pptxMagic bus Group work1and 2 (Team 3).pptx
Magic bus Group work1and 2 (Team 3).pptx
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptx
 
psychiatric nursing HISTORY COLLECTION .docx
psychiatric  nursing HISTORY  COLLECTION  .docxpsychiatric  nursing HISTORY  COLLECTION  .docx
psychiatric nursing HISTORY COLLECTION .docx
 
Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...
 
Seal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxSeal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptx
 
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.
 
Spatium Project Simulation student brief
Spatium Project Simulation student briefSpatium Project Simulation student brief
Spatium Project Simulation student brief
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...
 

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 ).