SlideShare a Scribd company logo
1 of 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….

More Related Content

What's hot (20)

System calls
System callsSystem calls
System calls
 
Memory management
Memory managementMemory management
Memory management
 
Difference Program vs Process vs Thread
Difference Program vs Process vs ThreadDifference Program vs Process vs Thread
Difference Program vs Process vs Thread
 
Disk scheduling
Disk schedulingDisk scheduling
Disk scheduling
 
Specification and complexity - algorithm
Specification and complexity - algorithmSpecification and complexity - algorithm
Specification and complexity - algorithm
 
INTER PROCESS COMMUNICATION (IPC).pptx
INTER PROCESS COMMUNICATION (IPC).pptxINTER PROCESS COMMUNICATION (IPC).pptx
INTER PROCESS COMMUNICATION (IPC).pptx
 
Time space trade off
Time space trade offTime space trade off
Time space trade off
 
Process of operating system
Process of operating systemProcess of operating system
Process of operating system
 
Process and Threads in Linux - PPT
Process and Threads in Linux - PPTProcess and Threads in Linux - PPT
Process and Threads in Linux - PPT
 
Os Threads
Os ThreadsOs Threads
Os Threads
 
Memory management
Memory managementMemory management
Memory management
 
Process scheduling
Process schedulingProcess scheduling
Process scheduling
 
process creation OS
process creation OSprocess creation OS
process creation OS
 
Page replacement algorithms
Page replacement algorithmsPage replacement algorithms
Page replacement algorithms
 
Multithreading
MultithreadingMultithreading
Multithreading
 
Symbol table in compiler Design
Symbol table in compiler DesignSymbol table in compiler Design
Symbol table in compiler Design
 
Processes and threads
Processes and threadsProcesses and threads
Processes and threads
 
Methods for handling deadlock
Methods for handling deadlockMethods for handling deadlock
Methods for handling deadlock
 
Operating Systems - "Chapter 4: Multithreaded Programming"
Operating Systems - "Chapter 4:  Multithreaded Programming"Operating Systems - "Chapter 4:  Multithreaded Programming"
Operating Systems - "Chapter 4: Multithreaded Programming"
 
CPU Scheduling Algorithms
CPU Scheduling AlgorithmsCPU Scheduling Algorithms
CPU Scheduling Algorithms
 

Viewers also liked (16)

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

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
 
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
 
Dot net guide for beginner
Dot net guide for beginner Dot net guide for beginner
Dot net guide for beginner jayc8586
 

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
 
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
 
Dot net guide for beginner
Dot net guide for beginner Dot net guide for beginner
Dot net guide for beginner
 

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

4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptx4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptxmary850239
 
Scientific Writing :Research Discourse
Scientific  Writing :Research  DiscourseScientific  Writing :Research  Discourse
Scientific Writing :Research DiscourseAnita GoswamiGiri
 
CLASSIFICATION OF ANTI - CANCER DRUGS.pptx
CLASSIFICATION OF ANTI - CANCER DRUGS.pptxCLASSIFICATION OF ANTI - CANCER DRUGS.pptx
CLASSIFICATION OF ANTI - CANCER DRUGS.pptxAnupam32727
 
31 ĐỀ THI THỬ VÀO LỚP 10 - TIẾNG ANH - FORM MỚI 2025 - 40 CÂU HỎI - BÙI VĂN V...
31 ĐỀ THI THỬ VÀO LỚP 10 - TIẾNG ANH - FORM MỚI 2025 - 40 CÂU HỎI - BÙI VĂN V...31 ĐỀ THI THỬ VÀO LỚP 10 - TIẾNG ANH - FORM MỚI 2025 - 40 CÂU HỎI - BÙI VĂN V...
31 ĐỀ THI THỬ VÀO LỚP 10 - TIẾNG ANH - FORM MỚI 2025 - 40 CÂU HỎI - BÙI VĂN V...Nguyen Thanh Tu Collection
 
Q-Factor HISPOL Quiz-6th April 2024, Quiz Club NITW
Q-Factor HISPOL Quiz-6th April 2024, Quiz Club NITWQ-Factor HISPOL Quiz-6th April 2024, Quiz Club NITW
Q-Factor HISPOL Quiz-6th April 2024, Quiz Club NITWQuiz Club NITW
 
ClimART Action | eTwinning Project
ClimART Action    |    eTwinning ProjectClimART Action    |    eTwinning Project
ClimART Action | eTwinning Projectjordimapav
 
Beauty Amidst the Bytes_ Unearthing Unexpected Advantages of the Digital Wast...
Beauty Amidst the Bytes_ Unearthing Unexpected Advantages of the Digital Wast...Beauty Amidst the Bytes_ Unearthing Unexpected Advantages of the Digital Wast...
Beauty Amidst the Bytes_ Unearthing Unexpected Advantages of the Digital Wast...DhatriParmar
 
MS4 level being good citizen -imperative- (1) (1).pdf
MS4 level   being good citizen -imperative- (1) (1).pdfMS4 level   being good citizen -imperative- (1) (1).pdf
MS4 level being good citizen -imperative- (1) (1).pdfMr Bounab Samir
 
Unraveling Hypertext_ Analyzing Postmodern Elements in Literature.pptx
Unraveling Hypertext_ Analyzing  Postmodern Elements in  Literature.pptxUnraveling Hypertext_ Analyzing  Postmodern Elements in  Literature.pptx
Unraveling Hypertext_ Analyzing Postmodern Elements in Literature.pptxDhatriParmar
 
Concurrency Control in Database Management system
Concurrency Control in Database Management systemConcurrency Control in Database Management system
Concurrency Control in Database Management systemChristalin Nelson
 
Decoding the Tweet _ Practical Criticism in the Age of Hashtag.pptx
Decoding the Tweet _ Practical Criticism in the Age of Hashtag.pptxDecoding the Tweet _ Practical Criticism in the Age of Hashtag.pptx
Decoding the Tweet _ Practical Criticism in the Age of Hashtag.pptxDhatriParmar
 
How to Manage Buy 3 Get 1 Free in Odoo 17
How to Manage Buy 3 Get 1 Free in Odoo 17How to Manage Buy 3 Get 1 Free in Odoo 17
How to Manage Buy 3 Get 1 Free in Odoo 17Celine George
 
ARTERIAL BLOOD GAS ANALYSIS........pptx
ARTERIAL BLOOD  GAS ANALYSIS........pptxARTERIAL BLOOD  GAS ANALYSIS........pptx
ARTERIAL BLOOD GAS ANALYSIS........pptxAneriPatwari
 
Active Learning Strategies (in short ALS).pdf
Active Learning Strategies (in short ALS).pdfActive Learning Strategies (in short ALS).pdf
Active Learning Strategies (in short ALS).pdfPatidar M
 
Team Lead Succeed – Helping you and your team achieve high-performance teamwo...
Team Lead Succeed – Helping you and your team achieve high-performance teamwo...Team Lead Succeed – Helping you and your team achieve high-performance teamwo...
Team Lead Succeed – Helping you and your team achieve high-performance teamwo...Association for Project Management
 
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdfGrade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdfJemuel Francisco
 
How to Make a Duplicate of Your Odoo 17 Database
How to Make a Duplicate of Your Odoo 17 DatabaseHow to Make a Duplicate of Your Odoo 17 Database
How to Make a Duplicate of Your Odoo 17 DatabaseCeline George
 

Recently uploaded (20)

4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptx4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptx
 
Scientific Writing :Research Discourse
Scientific  Writing :Research  DiscourseScientific  Writing :Research  Discourse
Scientific Writing :Research Discourse
 
CLASSIFICATION OF ANTI - CANCER DRUGS.pptx
CLASSIFICATION OF ANTI - CANCER DRUGS.pptxCLASSIFICATION OF ANTI - CANCER DRUGS.pptx
CLASSIFICATION OF ANTI - CANCER DRUGS.pptx
 
31 ĐỀ THI THỬ VÀO LỚP 10 - TIẾNG ANH - FORM MỚI 2025 - 40 CÂU HỎI - BÙI VĂN V...
31 ĐỀ THI THỬ VÀO LỚP 10 - TIẾNG ANH - FORM MỚI 2025 - 40 CÂU HỎI - BÙI VĂN V...31 ĐỀ THI THỬ VÀO LỚP 10 - TIẾNG ANH - FORM MỚI 2025 - 40 CÂU HỎI - BÙI VĂN V...
31 ĐỀ THI THỬ VÀO LỚP 10 - TIẾNG ANH - FORM MỚI 2025 - 40 CÂU HỎI - BÙI VĂN V...
 
Q-Factor HISPOL Quiz-6th April 2024, Quiz Club NITW
Q-Factor HISPOL Quiz-6th April 2024, Quiz Club NITWQ-Factor HISPOL Quiz-6th April 2024, Quiz Club NITW
Q-Factor HISPOL Quiz-6th April 2024, Quiz Club NITW
 
ClimART Action | eTwinning Project
ClimART Action    |    eTwinning ProjectClimART Action    |    eTwinning Project
ClimART Action | eTwinning Project
 
Beauty Amidst the Bytes_ Unearthing Unexpected Advantages of the Digital Wast...
Beauty Amidst the Bytes_ Unearthing Unexpected Advantages of the Digital Wast...Beauty Amidst the Bytes_ Unearthing Unexpected Advantages of the Digital Wast...
Beauty Amidst the Bytes_ Unearthing Unexpected Advantages of the Digital Wast...
 
MS4 level being good citizen -imperative- (1) (1).pdf
MS4 level   being good citizen -imperative- (1) (1).pdfMS4 level   being good citizen -imperative- (1) (1).pdf
MS4 level being good citizen -imperative- (1) (1).pdf
 
INCLUSIVE EDUCATION PRACTICES FOR TEACHERS AND TRAINERS.pptx
INCLUSIVE EDUCATION PRACTICES FOR TEACHERS AND TRAINERS.pptxINCLUSIVE EDUCATION PRACTICES FOR TEACHERS AND TRAINERS.pptx
INCLUSIVE EDUCATION PRACTICES FOR TEACHERS AND TRAINERS.pptx
 
Unraveling Hypertext_ Analyzing Postmodern Elements in Literature.pptx
Unraveling Hypertext_ Analyzing  Postmodern Elements in  Literature.pptxUnraveling Hypertext_ Analyzing  Postmodern Elements in  Literature.pptx
Unraveling Hypertext_ Analyzing Postmodern Elements in Literature.pptx
 
Concurrency Control in Database Management system
Concurrency Control in Database Management systemConcurrency Control in Database Management system
Concurrency Control in Database Management system
 
Mattingly "AI & Prompt Design: Large Language Models"
Mattingly "AI & Prompt Design: Large Language Models"Mattingly "AI & Prompt Design: Large Language Models"
Mattingly "AI & Prompt Design: Large Language Models"
 
Decoding the Tweet _ Practical Criticism in the Age of Hashtag.pptx
Decoding the Tweet _ Practical Criticism in the Age of Hashtag.pptxDecoding the Tweet _ Practical Criticism in the Age of Hashtag.pptx
Decoding the Tweet _ Practical Criticism in the Age of Hashtag.pptx
 
How to Manage Buy 3 Get 1 Free in Odoo 17
How to Manage Buy 3 Get 1 Free in Odoo 17How to Manage Buy 3 Get 1 Free in Odoo 17
How to Manage Buy 3 Get 1 Free in Odoo 17
 
ARTERIAL BLOOD GAS ANALYSIS........pptx
ARTERIAL BLOOD  GAS ANALYSIS........pptxARTERIAL BLOOD  GAS ANALYSIS........pptx
ARTERIAL BLOOD GAS ANALYSIS........pptx
 
Paradigm shift in nursing research by RS MEHTA
Paradigm shift in nursing research by RS MEHTAParadigm shift in nursing research by RS MEHTA
Paradigm shift in nursing research by RS MEHTA
 
Active Learning Strategies (in short ALS).pdf
Active Learning Strategies (in short ALS).pdfActive Learning Strategies (in short ALS).pdf
Active Learning Strategies (in short ALS).pdf
 
Team Lead Succeed – Helping you and your team achieve high-performance teamwo...
Team Lead Succeed – Helping you and your team achieve high-performance teamwo...Team Lead Succeed – Helping you and your team achieve high-performance teamwo...
Team Lead Succeed – Helping you and your team achieve high-performance teamwo...
 
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdfGrade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
 
How to Make a Duplicate of Your Odoo 17 Database
How to Make a Duplicate of Your Odoo 17 DatabaseHow to Make a Duplicate of Your Odoo 17 Database
How to Make a Duplicate of Your Odoo 17 Database
 

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