Fork

  • May 2020
  • PDF

This document was uploaded by user and they confirmed that they have the permission to share it. If you are author or own the copyright of this book, please report to us by using this DMCA report form. Report DMCA


Overview

Download & View Fork as PDF for free.

More details

  • Words: 890
  • Pages: 20
A Unix Process Text

Resources Resources

Data Stack

Process Status

File File

UNIX kernel

pid = 25 Text

How Fork Works Resources Resources

Data Stack

Process Status

File File

<…> int cpid = fork( ); if (cpid = = 0) { exit(0); } <parent code> wait(cpid);

UNIX kernel

pid = 25 Text

How Fork Works Resources Resources

Data Stack

Process Status

File File

pid = 26 Text

Data Stack

Process Status

<…> int cpid = fork( ); if (cpid = = 0) { exit(0); } <parent code> wait(cpid);

<…> int cpid = fork( ); if (cpid = = 0) { exit(0); } <parent code> wait(cpid);

UNIX kernel

pid = 25 Text

How Fork Works Resources Resources

Data

Text

Stack File File

Process Status

<…> int cpid = fork( ); if (cpid = = 0) { exit(0); } <parent code> wait(cpid);

UNIX kernel

Data Stack

Process Status

cpid = 0

cpid = 26

pid = 26

<…> int cpid = fork( ); if (cpid = = 0) { exit(0); } <parent code> wait(cpid);

pid = 25 Text

How Fork Works Resources Resources

Data

Text

Stack File File

Process Status

<…> int cpid = fork( ); if (cpid = = 0) { exit(0); } <parent code> wait(cpid);

UNIX kernel

Data Stack

Process Status

cpid = 0

cpid = 26

pid = 26

<…> int cpid = fork( ); if (cpid = = 0) { exit(0); } <parent code> wait(cpid);

pid = 25 Text

How Fork Works Resources Resources

Data

Text

Stack File File

Process Status

<…> int cpid = fork( ); if (cpid = = 0) { exit(0); } <parent code> wait(cpid);

UNIX kernel

Data Stack

Process Status

cpid = 0

cpid = 26

pid = 26

<…> int cpid = fork( ); if (cpid = = 0) { exit(0); } <parent code> wait(cpid);

pid = 25 Text

How Fork Works Resources Resources

Data

Text

Stack File File

Process Status

<…> int cpid = fork( ); if (cpid = = 0) { exit(0); } <parent code> wait(cpid);

UNIX kernel

Data Stack

Process Status

cpid = 0

cpid = 26

pid = 26

<…> int cpid = fork( ); if (cpid = = 0) { exit(0); } <parent code> wait(cpid);

pid = 25 Text

How Fork Works Resources Resources

Data

Text

Stack File File

Process Status

<…> int cpid = fork( ); if (cpid = = 0) { exit(0); } <parent code> wait(cpid);

UNIX kernel

Data Stack

Process Status

cpid = 0

cpid = 26

pid = 26

<…> int cpid = fork( ); if (cpid = = 0) { exit(0); } <parent code> wait(cpid);

pid = 25 Text

How Fork Works Resources Resources

Data

Text

Stack File File

Process Status

<…> int cpid = fork( ); if (cpid = = 0) { exit(0); } <parent code> wait(cpid);

UNIX kernel

Data Stack

Process Status

cpid = 0

cpid = 26

pid = 26

<…> int cpid = fork( ); if (cpid = = 0) { exit(0); } <parent code> wait(cpid);

pid = 25 Text

How Fork Works Resources Resources

Data Stack File File

Process Status

<…> int cpid = fork( ); if (cpid = = 0) { exit(0); } <parent code> wait(cpid);

cpid = 26

UNIX kernel

pid = 25 Text

How Fork Works Resources Resources

Data Stack File File

Process Status

<…> int cpid = fork( ); if (cpid = = 0) { exit(0); } <parent code> wait(cpid);

cpid = 26

UNIX kernel

pid = 25 Text

How Fork Works Resources Resources

Data Stack File File

Process Status

<…> int cpid = fork( ); if (cpid = = 0) { exit(0); } <parent code> wait(cpid);

cpid = 26

UNIX kernel

pid = 25 Text

How Fork Works Resources Resources

Data Stack File File

Process Status

<…> int cpid = fork( ); if (cpid = = 0) { exit(0); } <parent code> wait(cpid); <…>

cpid = 26

UNIX kernel

How Exec Works Resources Resources

Text

File File

Data Stack

Process Status

cpid = 0

UNIX kernel

pid = 26

<…> int cpid = fork( ); if (cpid = = 0) { exit(0); } <parent code> wait(cpid);

How Exec Works Resources Resources

Text

File File

UNIX kernel

Data Stack

Process Status

cpid = 0

foo

pid = 26

<…> int cpid = fork( ); if (cpid = = 0) { exec(“foo”); exit(0); } <parent code> wait(cpid);

How Exec Works Resources Resources

Text

File File

UNIX kernel

Data Stack

Process Status

cpid = 0

foo

pid = 26

<…> int cpid = fork( ); if (cpid = = 0) { exec(“foo”); exit(0); } <parent code> wait(cpid);

How Exec Works Resources Resources File File

foo

UNIX kernel

pid = 26

How Exec Works Resources Resources File File

pid = 26 Text

Data Stack

Process Status

<…> <…> <…> exit(0);

foo

UNIX kernel

How Exec Works Resources Resources File File

pid = 26 Text

Data Stack

Process Status

<…> <…> <…> exit(0);

UNIX kernel

How Exec Works Resources Resources File File

pid = 26 Text

Data Stack

Process Status

<…> <…> <…> exit(0);

UNIX kernel

Related Documents

Fork
May 2020 14
Rear Fork
May 2020 32
Front Fork
May 2020 23
Jones Fork Elementary
December 2019 1