Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8069413
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T13:00:41+00:00 2026-06-05T13:00:41+00:00

considering the following instruction: for(int i = 0; i < 3; i++) fork(); I

  • 0

considering the following instruction:

for(int i = 0; i < 3; i++)
    fork();

I try to figure out the number of created process and the steps of graph creation.

so the code above is equivalent than:

fork();
fork();
fork();

The official answer to this problem is illustrated with this graph:

graph

I am not able to visualize how this graph is created.

This is how I would have drawn the graph.

  1. so, the first fork will create a child copy (p2) of the parent process (p1). We have 2 process.

  2. the second fork, will duplicate p1 and p2 parents, by creating child process (p3 and p4).

  3. The third fork, will duplicate p1, p2, p3 and p4, by creating child process (p5, p6, p7, p8)

How can I obtain the same graph as my teacher?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T13:00:42+00:00Added an answer on June 5, 2026 at 1:00 pm

    If you want a graph similar to the official answer, try to stop thinking about how things run concurrently and instead concentrate on the generations of processes (parents, children, grandchildren and so on).

    At the start, there is one process p0, with three forks to go. When doing those three forks, it creates p1 with two forks to go, p2 with one fork to go and p3 with no forks left. Then p0 exits (only p1, p2 and p3 remain).

    We can toss away p3 since it has no forks left, leaving just p1 and p2).

    Process p1 then executes its second fork producing p4 with one fork left, then executes the third fork making p5 with no forks left. p1 is now done and exits (p2, p4 and p5 remain).

    Similar to p3, p5 can be tossed because it has no forks left. This leaves p2 and p4.

    Similarly, p2 had one fork left so it creates p6 with no forks left. Then both p2 and p6 exit due to having no forks left, leaving p4.

    Process p4 had one fork left so it creates p7 with no forks, and they both then exit.

    By drawing the chart with the depth based on parentage rather than when processes are started (although the starting time(a) controls where the process exists horizontally at a specific depth, eg, see p1, p2 and p3), your diagram should match the one given.

    So think of it this way:

      Sequence within generation -------->
    G
    e           ______p00______
    n          /       |       \
    e       p01       p02       p03
    r      /   \       |
    a   p04     p05   p06
    t    |
    i   p07
    o
    n
    |
    V
    

    (a) Keep in mind that starting time as defined here is when the process comes into existence – the order in which processes do actual useful work also depends on the vagaries of scheduling.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Considering following code: class Results { public int playerId; public int score; public int
Considering the following code public interface IEntity { int Id { get; set; }
Considering following code public class A { public static void main(String[] args) { new
Considering this article Developing a MVC component for Joomla , following is the code
Considering the following 2 lines of code (copied from w3schools.com > HTML < label
Considering the following c code: typedef struct ELE *tree_ptr struct ELE { long val;
This might be a dumb question, but considering the following semi-pseudo code. How do
Considering the following code public bool GetFalse() { return false; } public bool GetTrue()
Considering the following table: create table inttest ( someint INT(10) NULL DEFAULT NULL );
Considering the following code: <div style=float: left;> <select style=width: 160px;> <option>asd flkjh asdfkljha sdlkfjhasldjkfh

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.