Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

Fork in Operating System, Lecture notes of Operating Systems

Use of fork is explained in this ppt

Typology: Lecture notes

2017/2018

Uploaded on 04/30/2018

puneet-verma-1
puneet-verma-1 🇮🇳

1 document

1 / 16

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Operating Systems
CSM 604: Lecture 7
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff

Partial preview of the text

Download Fork in Operating System and more Lecture notes Operating Systems in PDF only on Docsity!

Operating Systems

CSM 604: Lecture 7

Process Management

Process

Memory Layout  (^) Text Section – executable code  (^) Data Section – global variables  (^) Stack – function parameters, return addresses and local variables.  (^) Heap – dynamically allocated during runtime  (^) Current Activity

Process Creation

Principal events that cause process creation

  1. System initialization
  2. Execution of a process creation system
  3. User request to create a new process
  4. Initiation of a batch job

fork()

fork()

main() { pid_t pid; pid = fork(); if (pid == 0) printf("\nI am the child %d\n",pid); else printf("\nI am the parent %d\n",pid); }

fork()

fork()

Process Creation

exec

int main(void) { int i; int status; pid_t pid; if(fork()) { pid = wait(&status); } else { execlp("date","date",0); } return 0; }

To be continued…

Questions?