SlideShare a Scribd company logo
Group E4
20CP205 AVNI ROHIT
21CP308 PARAM PATEL
21CP310 IRBAAZ VOHRA
1. Demonstrate the use of fork system call.
• Fork system call is used to create a new process, called the child
process.
• Child process runs concurrently with the process that makes the
fork() call, i.e. parent process.
• After a new child process is created, both processes will execute the
next instruction followed by the fork() system call.
• The fork() takes no parameters and returns an integer value.
• If the value < 0, then the creation of the child process failed.
• If value = 0, then returned to the newly created child process
• If value > 0, then parent is returned, and value = PID of child
process.
What is the output of the
following program?
 A)
 int main()
 {
 fork();
 printf("nHellon");
 return 0;
 }
OUTPUT
Parent
Process
Child
Process
Parent
Process
 B)
 int main()
 {
 fork();
 fork();
 printf("nHellon");
 return 0;
 }
Parent
Process
Parent
Process
Child
Process
(C1)
Parent
Process
Child
Process
(C2)
Child
Process
(C1)
Child
Process
(C3)
OUTPUT
2. Demonstrate printing PID of child
and parent process.
 #include <stdio.h>
 #include <sys/types.h>
 #include <unistd.h>
 int main()
 {
 int id = fork();
 if(id==0)
 {
 printf("nChild Process PID : %dn",getpid()
 printf("nParent PID : %dn",getppid());
 }
 else
 {
 printf(“nParent Process PID : %dn",getpid());
 sleep(2);
 }
 return 0;
 }
3. Demonstrate use of wait system call. How parent knows child
terminate normally or abnormally after checking return values of
wait .
A)
OUTPUT
B)
OUTPUT
4.Demonstrate use of execl, execv, execve, execlp,
execvp, execle.
 Execl :
execl() call replaces the image of the current process with
a new process image specified by the path i.e. the current
process code gets replaced by a new process code.
 Execv(path,argv) :
causes the current process to abandon the program that it is
running and start running the program in file path. Parameter
argv is the argument vector for the command, with a null
pointer at the end. It is an array of strings.
 Execve :
execve() executes the program pointed to by filename.
filename must be either a binary executable,
 execlp :
The execlp function is most commonly used to overlay a
process image that has been created by a call to the fork
function. identifies the location of the new process image
within the hierarchical file system (HFS).
 execvp and execle :
These two also serve the same purpose but the syntax of them
are a bit different from all the above members of exec family.
The syntaxes of both of them are shown below :
Syntax: int execvpe(const char *file, char *const argv[],char
*const envp[]);
Syntax:int execle(const char path, const char *arg, .../, (char
*) NULL, char * const envp[] */);
 5. Demonstrate Zombie Process and Orphan Process
 Zombie Process: A Process Which Terminate But Whose
Parent Not Yet Called Wait() is Known As Zombie Process
 Once The Parent Calls Wait() the Process Identifier of the
Process and its entry in the Zombie process the table is
released
 A child Process Always First Becomes a Zombie Before
Removed From the Process Table
 #include<stdio.h>
 #include<unistd.h>
 int main()
 {
 pid_t t;
 t=fork();
 if(t==0)
 {
 printf("Child having id %dn",getpid());
 }
 else
 {
 printf("Parent having id %dn",getpid());
 sleep(15); // Parent sleeps. Run the ps command
 }
 }
 Output :
 $gcc zombie.c
 $./a.out &
Orphan Process :
 A Process Whose Parent Process no More Exist i.e. either finished or
Terminated Without Waiting for Its Child Process To Terminate Is
Called an Orphan Process
 The Init Process Is Assigned As The New Parent To Orphan Process
 The Init Process Periodically Invokes wait(), There By Allowing The
Exit Status Of Any Orphaned Process to be collected and Relesing
Orphans Process identifier and Process Entry Table
#include<stdio.h >
 #include<unistd.h>
 #include<sys/types.h>
 int main()
 {
 pid_t p;
 p=fork();
 if(p==0)
 {
 sleep(5); //child goes to sleep and in the mean time parent
 terminates
 printf("I am child having PID %dn",getpid());
 printf("My parent PID is %dn",getppid());
 }
 else
 {
 Output :
6. Develop user defined function which allow to run
binary file and give control back to your parent process
similar to library function system
 Ex1.c
 #include<stdio.h>
 #include<unistd.h>
 #include<stdlib.h>
 Int main(int argc,char *argv[])
 {
 Printf(“PID of EX1.c= %dn”, getpid());
 Char *args[] = {“Hello”,”Vahora”,”Irbaz”,NULL};
 Execv(“./ex2”,args);
 Printf(“Back To ex1.c”);
 Return 0;
}
 Ex2.c
 #include<stdio.h>
 #include<unistd.h>
 #include<stdlib.h>
 Int main(int argc,char *argv[])
 {
 Printf(“We Are In Ex2.cn”)
 Printf(“PID of EX2.c= %dn”, getpid());
 Return 0;
}
OUTPUT
OS presentation (1).pptx

More Related Content

Similar to OS presentation (1).pptx

In Class AssignmetzCST280W13a-1.pdfCST 280 In-Class Pract.docx
In Class AssignmetzCST280W13a-1.pdfCST 280 In-Class Pract.docxIn Class AssignmetzCST280W13a-1.pdfCST 280 In-Class Pract.docx
In Class AssignmetzCST280W13a-1.pdfCST 280 In-Class Pract.docx
bradburgess22840
 
04_ForkPipe.pptx
04_ForkPipe.pptx04_ForkPipe.pptx
04_ForkPipe.pptx
vnwzympx
 
Jdk 7 4-forkjoin
Jdk 7 4-forkjoinJdk 7 4-forkjoin
Jdk 7 4-forkjoin
knight1128
 
11_UNIX_Processes_Including_Select.ppt
11_UNIX_Processes_Including_Select.ppt11_UNIX_Processes_Including_Select.ppt
11_UNIX_Processes_Including_Select.ppt
SIDDHARTHANANDCSE202
 
Programming Assignment #2CSci 430 Spring 2019Dates.docx
Programming Assignment #2CSci 430 Spring 2019Dates.docxProgramming Assignment #2CSci 430 Spring 2019Dates.docx
Programming Assignment #2CSci 430 Spring 2019Dates.docx
stilliegeorgiana
 
Programming Assignment #2CSci 430 Spring 2019Dates.docx
Programming Assignment #2CSci 430 Spring 2019Dates.docxProgramming Assignment #2CSci 430 Spring 2019Dates.docx
Programming Assignment #2CSci 430 Spring 2019Dates.docx
denneymargareta
 
SystemVerilog OOP Ovm Features Summary
SystemVerilog OOP Ovm Features SummarySystemVerilog OOP Ovm Features Summary
SystemVerilog OOP Ovm Features Summary
Amal Khailtash
 
httplinux.die.netman3execfork() creates a new process by.docx
httplinux.die.netman3execfork() creates a new process by.docxhttplinux.die.netman3execfork() creates a new process by.docx
httplinux.die.netman3execfork() creates a new process by.docx
adampcarr67227
 
Linux Systems Programming: Inter Process Communication (IPC) using Pipes
Linux Systems Programming: Inter Process Communication (IPC) using PipesLinux Systems Programming: Inter Process Communication (IPC) using Pipes
Linux Systems Programming: Inter Process Communication (IPC) using Pipes
RashidFaridChishti
 
Lect3 process
Lect3 processLect3 process
Lect3 process
santosh rao
 
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
wkyra78
 
Proces
ProcesProces
Proces
samof76
 
System Calls - Introduction
System Calls - IntroductionSystem Calls - Introduction
System Calls - Introduction
To Sum It Up
 
Java programs
Java programsJava programs
Using Flow-based programming to write tools and workflows for Scientific Comp...
Using Flow-based programming to write tools and workflows for Scientific Comp...Using Flow-based programming to write tools and workflows for Scientific Comp...
Using Flow-based programming to write tools and workflows for Scientific Comp...
Samuel Lampa
 
اسلاید اول جلسه هشتم کلاس پایتون برای هکرهای قانونی
اسلاید اول جلسه هشتم کلاس پایتون برای هکرهای قانونیاسلاید اول جلسه هشتم کلاس پایتون برای هکرهای قانونی
اسلاید اول جلسه هشتم کلاس پایتون برای هکرهای قانونی
Mohammad Reza Kamalifard
 
Mychurch File Upload
Mychurch File UploadMychurch File Upload
Mychurch File Upload
Joe Suh
 
Linux_C_LabBasics.ppt
Linux_C_LabBasics.pptLinux_C_LabBasics.ppt
Linux_C_LabBasics.ppt
CharuJain396881
 
Lecture2 process structure and programming
Lecture2   process structure and programmingLecture2   process structure and programming
Lecture2 process structure and programming
Mohammed Farrag
 
UNIX_Process Control_Module3.pptx
UNIX_Process Control_Module3.pptxUNIX_Process Control_Module3.pptx
UNIX_Process Control_Module3.pptx
raunakkumar290158
 

Similar to OS presentation (1).pptx (20)

In Class AssignmetzCST280W13a-1.pdfCST 280 In-Class Pract.docx
In Class AssignmetzCST280W13a-1.pdfCST 280 In-Class Pract.docxIn Class AssignmetzCST280W13a-1.pdfCST 280 In-Class Pract.docx
In Class AssignmetzCST280W13a-1.pdfCST 280 In-Class Pract.docx
 
04_ForkPipe.pptx
04_ForkPipe.pptx04_ForkPipe.pptx
04_ForkPipe.pptx
 
Jdk 7 4-forkjoin
Jdk 7 4-forkjoinJdk 7 4-forkjoin
Jdk 7 4-forkjoin
 
11_UNIX_Processes_Including_Select.ppt
11_UNIX_Processes_Including_Select.ppt11_UNIX_Processes_Including_Select.ppt
11_UNIX_Processes_Including_Select.ppt
 
Programming Assignment #2CSci 430 Spring 2019Dates.docx
Programming Assignment #2CSci 430 Spring 2019Dates.docxProgramming Assignment #2CSci 430 Spring 2019Dates.docx
Programming Assignment #2CSci 430 Spring 2019Dates.docx
 
Programming Assignment #2CSci 430 Spring 2019Dates.docx
Programming Assignment #2CSci 430 Spring 2019Dates.docxProgramming Assignment #2CSci 430 Spring 2019Dates.docx
Programming Assignment #2CSci 430 Spring 2019Dates.docx
 
SystemVerilog OOP Ovm Features Summary
SystemVerilog OOP Ovm Features SummarySystemVerilog OOP Ovm Features Summary
SystemVerilog OOP Ovm Features Summary
 
httplinux.die.netman3execfork() creates a new process by.docx
httplinux.die.netman3execfork() creates a new process by.docxhttplinux.die.netman3execfork() creates a new process by.docx
httplinux.die.netman3execfork() creates a new process by.docx
 
Linux Systems Programming: Inter Process Communication (IPC) using Pipes
Linux Systems Programming: Inter Process Communication (IPC) using PipesLinux Systems Programming: Inter Process Communication (IPC) using Pipes
Linux Systems Programming: Inter Process Communication (IPC) using Pipes
 
Lect3 process
Lect3 processLect3 process
Lect3 process
 
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
 
Proces
ProcesProces
Proces
 
System Calls - Introduction
System Calls - IntroductionSystem Calls - Introduction
System Calls - Introduction
 
Java programs
Java programsJava programs
Java programs
 
Using Flow-based programming to write tools and workflows for Scientific Comp...
Using Flow-based programming to write tools and workflows for Scientific Comp...Using Flow-based programming to write tools and workflows for Scientific Comp...
Using Flow-based programming to write tools and workflows for Scientific Comp...
 
اسلاید اول جلسه هشتم کلاس پایتون برای هکرهای قانونی
اسلاید اول جلسه هشتم کلاس پایتون برای هکرهای قانونیاسلاید اول جلسه هشتم کلاس پایتون برای هکرهای قانونی
اسلاید اول جلسه هشتم کلاس پایتون برای هکرهای قانونی
 
Mychurch File Upload
Mychurch File UploadMychurch File Upload
Mychurch File Upload
 
Linux_C_LabBasics.ppt
Linux_C_LabBasics.pptLinux_C_LabBasics.ppt
Linux_C_LabBasics.ppt
 
Lecture2 process structure and programming
Lecture2   process structure and programmingLecture2   process structure and programming
Lecture2 process structure and programming
 
UNIX_Process Control_Module3.pptx
UNIX_Process Control_Module3.pptxUNIX_Process Control_Module3.pptx
UNIX_Process Control_Module3.pptx
 

Recently uploaded

Azure API Management to expose backend services securely
Azure API Management to expose backend services securelyAzure API Management to expose backend services securely
Azure API Management to expose backend services securely
Dinusha Kumarasiri
 
Presentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of GermanyPresentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of Germany
innovationoecd
 
Digital Marketing Trends in 2024 | Guide for Staying Ahead
Digital Marketing Trends in 2024 | Guide for Staying AheadDigital Marketing Trends in 2024 | Guide for Staying Ahead
Digital Marketing Trends in 2024 | Guide for Staying Ahead
Wask
 
Programming Foundation Models with DSPy - Meetup Slides
Programming Foundation Models with DSPy - Meetup SlidesProgramming Foundation Models with DSPy - Meetup Slides
Programming Foundation Models with DSPy - Meetup Slides
Zilliz
 
FREE A4 Cyber Security Awareness Posters-Social Engineering part 3
FREE A4 Cyber Security Awareness  Posters-Social Engineering part 3FREE A4 Cyber Security Awareness  Posters-Social Engineering part 3
FREE A4 Cyber Security Awareness Posters-Social Engineering part 3
Data Hops
 
Best 20 SEO Techniques To Improve Website Visibility In SERP
Best 20 SEO Techniques To Improve Website Visibility In SERPBest 20 SEO Techniques To Improve Website Visibility In SERP
Best 20 SEO Techniques To Improve Website Visibility In SERP
Pixlogix Infotech
 
Building Production Ready Search Pipelines with Spark and Milvus
Building Production Ready Search Pipelines with Spark and MilvusBuilding Production Ready Search Pipelines with Spark and Milvus
Building Production Ready Search Pipelines with Spark and Milvus
Zilliz
 
Astute Business Solutions | Oracle Cloud Partner |
Astute Business Solutions | Oracle Cloud Partner |Astute Business Solutions | Oracle Cloud Partner |
Astute Business Solutions | Oracle Cloud Partner |
AstuteBusiness
 
Your One-Stop Shop for Python Success: Top 10 US Python Development Providers
Your One-Stop Shop for Python Success: Top 10 US Python Development ProvidersYour One-Stop Shop for Python Success: Top 10 US Python Development Providers
Your One-Stop Shop for Python Success: Top 10 US Python Development Providers
akankshawande
 
Nordic Marketo Engage User Group_June 13_ 2024.pptx
Nordic Marketo Engage User Group_June 13_ 2024.pptxNordic Marketo Engage User Group_June 13_ 2024.pptx
Nordic Marketo Engage User Group_June 13_ 2024.pptx
MichaelKnudsen27
 
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdfHow to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
Chart Kalyan
 
June Patch Tuesday
June Patch TuesdayJune Patch Tuesday
June Patch Tuesday
Ivanti
 
AWS Cloud Cost Optimization Presentation.pptx
AWS Cloud Cost Optimization Presentation.pptxAWS Cloud Cost Optimization Presentation.pptx
AWS Cloud Cost Optimization Presentation.pptx
HarisZaheer8
 
Energy Efficient Video Encoding for Cloud and Edge Computing Instances
Energy Efficient Video Encoding for Cloud and Edge Computing InstancesEnergy Efficient Video Encoding for Cloud and Edge Computing Instances
Energy Efficient Video Encoding for Cloud and Edge Computing Instances
Alpen-Adria-Universität
 
zkStudyClub - LatticeFold: A Lattice-based Folding Scheme and its Application...
zkStudyClub - LatticeFold: A Lattice-based Folding Scheme and its Application...zkStudyClub - LatticeFold: A Lattice-based Folding Scheme and its Application...
zkStudyClub - LatticeFold: A Lattice-based Folding Scheme and its Application...
Alex Pruden
 
Public CyberSecurity Awareness Presentation 2024.pptx
Public CyberSecurity Awareness Presentation 2024.pptxPublic CyberSecurity Awareness Presentation 2024.pptx
Public CyberSecurity Awareness Presentation 2024.pptx
marufrahmanstratejm
 
Serial Arm Control in Real Time Presentation
Serial Arm Control in Real Time PresentationSerial Arm Control in Real Time Presentation
Serial Arm Control in Real Time Presentation
tolgahangng
 
dbms calicut university B. sc Cs 4th sem.pdf
dbms  calicut university B. sc Cs 4th sem.pdfdbms  calicut university B. sc Cs 4th sem.pdf
dbms calicut university B. sc Cs 4th sem.pdf
Shinana2
 
A Comprehensive Guide to DeFi Development Services in 2024
A Comprehensive Guide to DeFi Development Services in 2024A Comprehensive Guide to DeFi Development Services in 2024
A Comprehensive Guide to DeFi Development Services in 2024
Intelisync
 
5th LF Energy Power Grid Model Meet-up Slides
5th LF Energy Power Grid Model Meet-up Slides5th LF Energy Power Grid Model Meet-up Slides
5th LF Energy Power Grid Model Meet-up Slides
DanBrown980551
 

Recently uploaded (20)

Azure API Management to expose backend services securely
Azure API Management to expose backend services securelyAzure API Management to expose backend services securely
Azure API Management to expose backend services securely
 
Presentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of GermanyPresentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of Germany
 
Digital Marketing Trends in 2024 | Guide for Staying Ahead
Digital Marketing Trends in 2024 | Guide for Staying AheadDigital Marketing Trends in 2024 | Guide for Staying Ahead
Digital Marketing Trends in 2024 | Guide for Staying Ahead
 
Programming Foundation Models with DSPy - Meetup Slides
Programming Foundation Models with DSPy - Meetup SlidesProgramming Foundation Models with DSPy - Meetup Slides
Programming Foundation Models with DSPy - Meetup Slides
 
FREE A4 Cyber Security Awareness Posters-Social Engineering part 3
FREE A4 Cyber Security Awareness  Posters-Social Engineering part 3FREE A4 Cyber Security Awareness  Posters-Social Engineering part 3
FREE A4 Cyber Security Awareness Posters-Social Engineering part 3
 
Best 20 SEO Techniques To Improve Website Visibility In SERP
Best 20 SEO Techniques To Improve Website Visibility In SERPBest 20 SEO Techniques To Improve Website Visibility In SERP
Best 20 SEO Techniques To Improve Website Visibility In SERP
 
Building Production Ready Search Pipelines with Spark and Milvus
Building Production Ready Search Pipelines with Spark and MilvusBuilding Production Ready Search Pipelines with Spark and Milvus
Building Production Ready Search Pipelines with Spark and Milvus
 
Astute Business Solutions | Oracle Cloud Partner |
Astute Business Solutions | Oracle Cloud Partner |Astute Business Solutions | Oracle Cloud Partner |
Astute Business Solutions | Oracle Cloud Partner |
 
Your One-Stop Shop for Python Success: Top 10 US Python Development Providers
Your One-Stop Shop for Python Success: Top 10 US Python Development ProvidersYour One-Stop Shop for Python Success: Top 10 US Python Development Providers
Your One-Stop Shop for Python Success: Top 10 US Python Development Providers
 
Nordic Marketo Engage User Group_June 13_ 2024.pptx
Nordic Marketo Engage User Group_June 13_ 2024.pptxNordic Marketo Engage User Group_June 13_ 2024.pptx
Nordic Marketo Engage User Group_June 13_ 2024.pptx
 
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdfHow to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
 
June Patch Tuesday
June Patch TuesdayJune Patch Tuesday
June Patch Tuesday
 
AWS Cloud Cost Optimization Presentation.pptx
AWS Cloud Cost Optimization Presentation.pptxAWS Cloud Cost Optimization Presentation.pptx
AWS Cloud Cost Optimization Presentation.pptx
 
Energy Efficient Video Encoding for Cloud and Edge Computing Instances
Energy Efficient Video Encoding for Cloud and Edge Computing InstancesEnergy Efficient Video Encoding for Cloud and Edge Computing Instances
Energy Efficient Video Encoding for Cloud and Edge Computing Instances
 
zkStudyClub - LatticeFold: A Lattice-based Folding Scheme and its Application...
zkStudyClub - LatticeFold: A Lattice-based Folding Scheme and its Application...zkStudyClub - LatticeFold: A Lattice-based Folding Scheme and its Application...
zkStudyClub - LatticeFold: A Lattice-based Folding Scheme and its Application...
 
Public CyberSecurity Awareness Presentation 2024.pptx
Public CyberSecurity Awareness Presentation 2024.pptxPublic CyberSecurity Awareness Presentation 2024.pptx
Public CyberSecurity Awareness Presentation 2024.pptx
 
Serial Arm Control in Real Time Presentation
Serial Arm Control in Real Time PresentationSerial Arm Control in Real Time Presentation
Serial Arm Control in Real Time Presentation
 
dbms calicut university B. sc Cs 4th sem.pdf
dbms  calicut university B. sc Cs 4th sem.pdfdbms  calicut university B. sc Cs 4th sem.pdf
dbms calicut university B. sc Cs 4th sem.pdf
 
A Comprehensive Guide to DeFi Development Services in 2024
A Comprehensive Guide to DeFi Development Services in 2024A Comprehensive Guide to DeFi Development Services in 2024
A Comprehensive Guide to DeFi Development Services in 2024
 
5th LF Energy Power Grid Model Meet-up Slides
5th LF Energy Power Grid Model Meet-up Slides5th LF Energy Power Grid Model Meet-up Slides
5th LF Energy Power Grid Model Meet-up Slides
 

OS presentation (1).pptx

  • 1. Group E4 20CP205 AVNI ROHIT 21CP308 PARAM PATEL 21CP310 IRBAAZ VOHRA
  • 2. 1. Demonstrate the use of fork system call. • Fork system call is used to create a new process, called the child process. • Child process runs concurrently with the process that makes the fork() call, i.e. parent process. • After a new child process is created, both processes will execute the next instruction followed by the fork() system call. • The fork() takes no parameters and returns an integer value. • If the value < 0, then the creation of the child process failed. • If value = 0, then returned to the newly created child process • If value > 0, then parent is returned, and value = PID of child process.
  • 3. What is the output of the following program?  A)  int main()  {  fork();  printf("nHellon");  return 0;  }
  • 5.  B)  int main()  {  fork();  fork();  printf("nHellon");  return 0;  } Parent Process Parent Process Child Process (C1) Parent Process Child Process (C2) Child Process (C1) Child Process (C3)
  • 7. 2. Demonstrate printing PID of child and parent process.  #include <stdio.h>  #include <sys/types.h>  #include <unistd.h>  int main()  {  int id = fork();  if(id==0)  {  printf("nChild Process PID : %dn",getpid()  printf("nParent PID : %dn",getppid());  }
  • 8.  else  {  printf(“nParent Process PID : %dn",getpid());  sleep(2);  }  return 0;  }
  • 9.
  • 10. 3. Demonstrate use of wait system call. How parent knows child terminate normally or abnormally after checking return values of wait . A)
  • 12. B)
  • 14. 4.Demonstrate use of execl, execv, execve, execlp, execvp, execle.  Execl : execl() call replaces the image of the current process with a new process image specified by the path i.e. the current process code gets replaced by a new process code.
  • 15.  Execv(path,argv) : causes the current process to abandon the program that it is running and start running the program in file path. Parameter argv is the argument vector for the command, with a null pointer at the end. It is an array of strings.  Execve : execve() executes the program pointed to by filename. filename must be either a binary executable,
  • 16.  execlp : The execlp function is most commonly used to overlay a process image that has been created by a call to the fork function. identifies the location of the new process image within the hierarchical file system (HFS).
  • 17.  execvp and execle : These two also serve the same purpose but the syntax of them are a bit different from all the above members of exec family. The syntaxes of both of them are shown below : Syntax: int execvpe(const char *file, char *const argv[],char *const envp[]); Syntax:int execle(const char path, const char *arg, .../, (char *) NULL, char * const envp[] */);
  • 18.  5. Demonstrate Zombie Process and Orphan Process  Zombie Process: A Process Which Terminate But Whose Parent Not Yet Called Wait() is Known As Zombie Process  Once The Parent Calls Wait() the Process Identifier of the Process and its entry in the Zombie process the table is released  A child Process Always First Becomes a Zombie Before Removed From the Process Table
  • 19.  #include<stdio.h>  #include<unistd.h>  int main()  {  pid_t t;  t=fork();  if(t==0)  {  printf("Child having id %dn",getpid());  }  else  {  printf("Parent having id %dn",getpid());  sleep(15); // Parent sleeps. Run the ps command  }  }
  • 20.  Output :  $gcc zombie.c  $./a.out &
  • 21. Orphan Process :  A Process Whose Parent Process no More Exist i.e. either finished or Terminated Without Waiting for Its Child Process To Terminate Is Called an Orphan Process  The Init Process Is Assigned As The New Parent To Orphan Process  The Init Process Periodically Invokes wait(), There By Allowing The Exit Status Of Any Orphaned Process to be collected and Relesing Orphans Process identifier and Process Entry Table
  • 22. #include<stdio.h >  #include<unistd.h>  #include<sys/types.h>  int main()  {  pid_t p;  p=fork();  if(p==0)  {  sleep(5); //child goes to sleep and in the mean time parent  terminates  printf("I am child having PID %dn",getpid());  printf("My parent PID is %dn",getppid());  }  else  {
  • 24. 6. Develop user defined function which allow to run binary file and give control back to your parent process similar to library function system  Ex1.c  #include<stdio.h>  #include<unistd.h>  #include<stdlib.h>  Int main(int argc,char *argv[])  {  Printf(“PID of EX1.c= %dn”, getpid());  Char *args[] = {“Hello”,”Vahora”,”Irbaz”,NULL};  Execv(“./ex2”,args);  Printf(“Back To ex1.c”);  Return 0; }
  • 25.  Ex2.c  #include<stdio.h>  #include<unistd.h>  #include<stdlib.h>  Int main(int argc,char *argv[])  {  Printf(“We Are In Ex2.cn”)  Printf(“PID of EX2.c= %dn”, getpid());  Return 0; }