Comp3511 Hw1 Solution Essay

1128 Words Nov 29th, 2011 5 Pages
Fall 2011 COMP 3511 Homework Assignment #1 Solution
Handout Date: Sept. 22, 2011 Due Date: Oct. 6, 2011
Name: ______________ ID: ___________________ E-Mail: _____________ COMP 3511 L __ Please read the following instructions carefully before answering the questions:  You should finish the homework assignment individually.  There are a total of 4 questions.  When you write your answers, please try to be precise and concise.  Fill in your name, student ID, email and Section number at the top of each page. Submissions without this information will be discarded.  Please fill in your answers in the space provided, or you can type your answers in a Word file.  Homework Collection: the hardcopy is required and the homework is collected at
…show more content…
Or this also makes it more reliable and secure, since most services are running in user mode, not in kernel mode. Disadvantages: this adds overhead for system calls or suffer from performance degradation.

2.

(20 points) Fork(). (1) (10 points) You have executed the following C program: main () { int pid; pid = fork (); if (pid) printf ("Parent runs\n"); else printf(“Child runs\n”); } What are the possible outputs, assuming the fork succeeded? Answer: Child runs Parent runs Or Parent runs Child runs (2) (10 points) You have executed the following C program: main() { int pid; int x = 0; pid = fork (); if (pid) { x = x + 1; printf ("The value of x in Parent is %d\n", x);

} else { x = x + 1; printf ("The value of x in Child is %d\n", x); } } Please show all possible outputs, assuming the fork succeeded. Answer: The value of x in Parent is 1 The value of x in Child is 1 or The value of x in Child is 1 The value of x in Parent is 1

3.

(26 points) Process 1) (4 points) There are two states in a process, new and terminated. What is the use of them?

Answer: Allocating and de-allocating resources 2) (8 points) What are the 4 steps in creating a process?

Answer: construct a new PCB, set up new pages table for address space or simply set up memory space, copy data from parent process, copy I/O status. 3)

Related Documents