Unit4 - Subjective Questions

CSE325 • Practice Questions with Detailed Answers

1

Explain the working of the fork() system call. What are the possible return values, and what do they signify?

2

Differentiate between a Zombie Process and an Orphan Process. How does the operating system handle them?

3

Describe the exec() family of functions. Why is exec() often used immediately after fork()?

4

Write a C program to demonstrate the creation of a Zombie process. Explain the logic.

5

Explain the syntax and utility of the wait() system call. How does it assist in process synchronization?

6

Compare wait() and waitpid() system calls. Why might a programmer prefer waitpid()?

7

Analyze the following code snippet. How many times will "Hello" be printed? Justify your answer mathematically.

c

include <stdio.h>

include <unistd.h>

int main() {
fork();
fork();
fork();
printf("Hello\n");
return 0;
}

8

What are Signals in an Operating System? List and explain three common signals used in Linux.

9

Write a C program to implement an Orphan process.

10

Explain how the kill() system call works. Does it always kill a process?

11

Discuss the various variants of the exec family (execl, execv, execle, execvp). How do their arguments differ?

12

What are the macros used to inspect the status integer returned by wait()? Explain any three.

13

Write a C program that creates a child process. The parent should wait for the child to finish and then print the exit status of the child.

14

What is Copy-on-Write (CoW) in the context of fork()? How does it optimize process creation?

15

How can a process handle signals? Explain the signal() system call with an example of handling SIGINT.

16

Explain the concept of Process Groups and how signals can be sent to a whole group.

17

What happens to open file descriptors when fork() is called? Explain with a scenario.

18

Derive the number of times the printf statement is executed in the following code:
c
for(int i=0; i<n; i++) {
fork();
}
printf("OS\n");

19

Why is the init process (or systemd) critical in the context of process management and orphans?

20

Explain the difference between exit() and _exit() system calls.