Introduction To Operating Systems NPTEL Week 3 Assignment

These are solution for Introduction To Operating Systems NPTEL Week 3 Assignment

Course Name: Introduction To Operating Systems

Link of course: Click here


Q1) int main(){

int i, n;

for(i=1;i<n; i++){

if (fork() == 0)

printf(“OS”);

printf(“NPTEL”);

}

Number of times OS and NPTEL printed ?

a. 2^n and 2^n

b. 2^(n-1) and 2^(n-1)

c. 2^(n-1)-1 and 2^(n-1)

d. 2^n and 2^(n-1)

Answer: c. 2^(n-1)-1 and 2^(n-1)


These are solution for Introduction To Operating Systems NPTEL Week 3 Assignment


Q2) State True or False.

A program to compute the sum of first 5,000 numbers can be divided into 4 sub parts and executed on 4 CPUs using either fork or threads. The reason why we prefer fork is because large portions of the data/code between the 4 sub-parts are very similar and need not be duplicated.

a. True

b.False

Answer: a. True


Q3) Match the following :

1.NEW A. Waiting for an i/o

2.READY B. Currently Executing

3.RUNNING C. Process is being created

4.SLEEPING D. waiting to be picked up by scheduler

a. 1-A, 2-D, 3-B, 4-C

b. 1-C, 2-B, 3-D, 4-A

c. 1-A, 2-C, 3-D, 4-B

d. 1-C, 2-D, 3-B, 4-A

Answer: d. 1-C, 2-D, 3-B, 4-A


These are solution for Introduction To Operating Systems NPTEL Week 3 Assignment


Q4) State True or False for a process currently in RUNNING state. A software interrupt will result in the change to ring 1.

a. True

b. False

Answer: b. False


Q5) State True or False. In the absence of system calls, a user process can never dynamically allocate memory.

a. True

b. False

Answer: a. True


These are solution for Introduction To Operating Systems NPTEL Week 3 Assignment


Q6) The wait() system call inside the parent process returns the pid of an exiting child process. Which of the following best fits when wait is called inside the child process?

a. Returns -1, when the child is not the parent of any other process

b. Returns its own process id.

c. Returns the exit status of the parent currently exited.

d. Such a call is not feasible and is likely to crash the process.

Answer: a. Returns -1, when the child is not the parent of any other process


These are solution for Introduction To Operating Systems NPTEL Week 3 Assignment


Q7) A student has written a program and used pid = fork() function call in it. The pid returned by the fork was 5129. Which of the following is true about the process invoking fork?

a. Process is a parent process with pid=5129

b. Process is a child process. Its Parent’s pid is 5129

c. The process is a parent process. Its Child’s pid is 5129

d. Process is a child process with pid = 5129

Answer: c. The process is a parent process. Its Child’s pid is 5129


Q8) State True/False

When the child process state is set to Zombie, all page directories and the kernel are also deallocated.

a. True

b. False

Answer: b. False


These are solution for Introduction To Operating Systems NPTEL Week 3 Assignment


Q9) Which of the below statement is False.

a. Kernel stack can be used to store the context of a process.

b. User stack is used to store the function details during function calls.

c. Kernel stack is used to store the function arguments during systems calls.

d. Context of the process is useful to restart the process after some time.

Answer: d. Context of the process is useful to restart the process after some time.


Q10) What is the output in the parent process? int main() { int a=0, pid; pid = fork(); if(pid == 0){ a= a – 10; printf(“u = %d\n”, a); } else{ a= a + 10; printf(“x = %d\n”,a); } }

a. U = -10

b. X = 10

c. x=0

d. U = 10

Answer: b. X = 10


These are solution for Introduction To Operating Systems NPTEL Week 3 Assignment

All weeks of Introduction To Operating Systems: https://progies.in/answers/nptel/introduction-to-operating-systems

More NPTEL Solutions: https://progies.in/answers/nptel


* The material and content uploaded on this website are for general information and reference purposes only. Please do it by your own first. COPYING MATERIALS IS STRICTLY PROHIBITED.


More from PROGIEZ

These are solution for Introduction To Operating Systems NPTEL Week 3 Assignment