1. Homepage
  2. Exam
  3. [2021] COMP1411 Introduction to Computer Systems - Q5 Process Graph

[2021] COMP1411 Introduction to Computer Systems - Q5 Process Graph

This question has been solved
Engage in a Conversation

Question 5. [25 marks]


CourseNana.COM

Consider the execution of the following program (written in the C language). CourseNana.COM

// all headers needed are included CourseNana.COM

int main() CourseNana.COM

{ CourseNana.COM

int i = 0; CourseNana.COM

while (i < 3){ CourseNana.COM

if (fork() == 0){ CourseNana.COM

i++; CourseNana.COM

} CourseNana.COM

i++; CourseNana.COM

printf("%d ", i); fflush(stdout); CourseNana.COM

waitpid(-1, NULL, 0); CourseNana.COM

} CourseNana.COM

return; CourseNana.COM

} CourseNana.COM

  CourseNana.COM

5(a) Draw the process graph for the main() function. [15 marks] CourseNana.COM

You should include main(), fork(), printf(), waitpid() in your process graph; you can skip fflush() in drawing the process graph; “i++” does not appear in the process graph. CourseNana.COM

Note that a process graph should not have any cycle. For example, let A and B are vertices in a process graph, “A →B →A” composes a cycle. If a function is invoked many times, each invocation should have a vertex in the process graph. CourseNana.COM

  CourseNana.COM

5(b) Calculate the number of feasible outputs of this program. [10 marks] CourseNana.COM

Show your steps on how you do the calculation step-by-step, with explanation of what program behaviors lead to the number of feasible outputs. CourseNana.COM

CourseNana.COM

Get the Solution to This Question

WeChat WeChat
Whatsapp WhatsApp
The Hong Kong Polytechnic University代写,COMP1411代写,Introduction to Computer Systems代写,Assembly Language代写,The Hong Kong Polytechnic University代编,COMP1411代编,Introduction to Computer Systems代编,Assembly Language代编,The Hong Kong Polytechnic University代考,COMP1411代考,Introduction to Computer Systems代考,Assembly Language代考,The Hong Kong Polytechnic Universityhelp,COMP1411help,Introduction to Computer Systemshelp,Assembly Languagehelp,The Hong Kong Polytechnic University作业代写,COMP1411作业代写,Introduction to Computer Systems作业代写,Assembly Language作业代写,The Hong Kong Polytechnic University编程代写,COMP1411编程代写,Introduction to Computer Systems编程代写,Assembly Language编程代写,The Hong Kong Polytechnic Universityprogramming help,COMP1411programming help,Introduction to Computer Systemsprogramming help,Assembly Languageprogramming help,The Hong Kong Polytechnic Universityassignment help,COMP1411assignment help,Introduction to Computer Systemsassignment help,Assembly Languageassignment help,The Hong Kong Polytechnic Universitysolution,COMP1411solution,Introduction to Computer Systemssolution,Assembly Languagesolution,