Introduction To Operating Systems NPTEL Week 3 Assignment

Session: JULY-DEC 2023

Course Name: Introduction to Operating Systems

Course Link: Click Here

These are Introduction to Operating Systems NPTEL Assignment 3 Answers


Q1. Match the following
a. Inode 1) The pid is assigned to a process
b. New state 2)Never exits
c. Trapframe 3)Stores metadata
d. init 4) For restarting a process after a context switch

a-4, b-2, c-3, d-1
a-3, b-4, c-2, d-1
a-4, b-1, c-2, d-3
a-3, b-1, c-4, d-2

Answer: a-3, b-1, c-4, d-2


Q2. We have n number of fork system calls, denoted as nXfork(). What is the total number of process created?
n
2^n
2^(n-1)
(2^n) – 1

Answer: 2^n


Q3. State True/ False
The process whose parent exited before the child is an orphan process. Can a process can be Zombie and Orphan at the same time.

True
False

Answer: False


These are Introduction to Operating Systems NPTEL Assignment 3 Answers


Q4. What is the output of the following program for any value of a
u =x+5
x=u+5
x=u+10
u=x+10

Answer: u =x+5


Q5. Which of the below statement is false.
Init is the first process created using booting
Init process is a daemon process.
Init process have process identifier as 1
None of these

Answer: None of these


Q6. A student have written a program and used pid = fork() function call in it. The pid returned by the fork was 5119. Which of the following is true about the process invoking fork?
Process is a parent process with pid = 5119
Process is a child process. Its Parent’s pid is 5119
The process is a parent process. Its Child’s pid is 5119
Process is a child process with pid = 5119

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


These are Introduction to Operating Systems NPTEL Assignment 3 Answers


Q7. Which of the following is false?
Process : Contains code+data+heap+stack+process state
Program : One program can be used to create many processes
Process : Process is not a unique isolated entity
Program : Code + Static and Global data

Answer: Process : Process is not a unique isolated entity


Q8. The state transition that occurs due to the scanf system call in the program is ______.
NEW -> READY
READY -> RUNNING
RUNNING -> BLOCKED
BLOCKED -> READY

Answer: RUNNING -> BLOCKED


Q9. Which one of the following is the property of Operating system that helps to prevent attacks?
i)Rings
ii) a separate stack for the kernel
iii)Virtual memory
iv) Shared Libraries

i
i, ii
i, ii, iii
i, ii, iii, iv

Answer: i, ii


These are Introduction to Operating Systems NPTEL Assignment 3 Answers


Q10. State True or False.
1. If the parent and the child process share the same page table. Does this mean they share the same page frames in the RAM?
2. COW creates a copy of the shared pages if it changes. All further changes are made in this new page.

True, False
False, True
False, False
True, True

Answer: True, True


Q11. Match the following
a. Init.d 1) Created when system call occurs
b. Zombie 2) The %eax register is cleared when this is created
c. Child process 3) Created by kernel while booting
d. Trapframe 4) Allows a parent process to read the status of child

a-1, b-2, c-3, d-4
a-3, b-4, c-2, d-1
a-2, b-1, c-4, d-3
a-4, b-3, c-1, d-2

Answer: a-3, b-4, c-2, d-1


Q12. State True/False
In memory mapping, the entire kernel is mapped into process’ address space, which helps the user process to easily access the kernel data.

True
False

Answer: False


These are Introduction to Operating Systems NPTEL Assignment 3 Answers


Q13. Arrange the following in order
a. Change state to runnable
b. Copy page directory contents from parent to child process
c. Copy the trapframe from the parent process
d. Change state to embryo

a, c, b, d
c, d, a, b
d, b, c, a
a, c, b, d

Answer: d, b, c, a


Q14. wait() system call inside the parent process returns the status of the child. What does it returns when it is called inside the child?
Returns -1 , when it is not the parent of any other process
Returns its own process id
Returns the exit status of the parent currently exited.
None of these.

Answer: Returns -1 , when it is not the parent of any other process


Q15. State True/False
execlp() system call replaces the child process with a new program file, but the process ID will not change.

True
False

Answer: True


These are Introduction to Operating Systems NPTEL Assignment 3 Answers

More Weeks of Introduction to Operating Systems: Click here

More Nptel Courses: Click here


These are Introduction to Operating Systems NPTEL Assignment 3 Answers

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 Introduction to Operating Systems NPTEL Assignment 3 Answers


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


These are Introduction to Operating Systems NPTEL Assignment 3 Answers


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 Introduction to Operating Systems NPTEL Assignment 3 Answers


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 Introduction to Operating Systems NPTEL Assignment 3 Answers


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 Introduction to Operating Systems NPTEL Assignment 3 Answers


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 Introduction to Operating Systems NPTEL Assignment 3 Answers


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.


These are Introduction to Operating Systems NPTEL Assignment 3 Answers


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 Introduction to Operating Systems NPTEL Assignment 3 Answers


Introduction to Operating Systems NPTEL Assignment 3
The content uploaded on this website is for reference purposes only. Please do it yourself first.