Question Type: This question tests knowledge of process management in operating systems, specifically focusing on the use of system calls for creating and managing processes.
Step-by-Step Logic:
fork() system call is used to create a new process, which is a copy of the parent process. After a successful fork(), the parent and child processes both continue execution from the point of the fork() call.join() system call (or a similar mechanism depending on the operating system) allows a parent process to wait for the termination of a child process before continuing its own execution. This ensures that the parent process doesn't proceed until the child process completes its task.fork()) to perform a specific task, and the parent process waits for the child process to finish before continuing (using join() or an equivalent). This is a fundamental pattern in concurrent programming to ensure proper synchronization and order of execution.Core Logic/Pattern: The core logic lies in the understanding of how fork() creates a new process and how join() synchronizes the parent and child process executions. They are used together to build complete process subroutines.
Eliminate Incorrect Options:
sleep() pauses the execution of a process for a specified time. It doesn't coordinate the completion of a child process.sleep() alone doesn't initiate a child process. join() needs a process to wait for.fork()) *before* waiting for its completion (join()).Correct Answer: Option 1 (fork(), join()) is correct because it demonstrates the standard pattern for creating and synchronizing the execution of a child process within a parent process subroutine.
A computer system has 7 tape drives. There are ‘n’ processes competing for them. Each process may need 2 tape drives. What is the maximum value of ‘n’ for which the system is guaranteed to be deadlock free?
Assuming that the system call fork () never fails, consider the following C programs P1 and P2 executed on a UNIX / Linux system:
/*P1*/ Int main() { fork (): fork () ; fork () ; Printf(“Happy\n”); } | /*P2*/ Int main() { fork (); Printf(“Happy\n”); fork () Printf(“Happy\n”); fork () ; Printf(“Happy\n”); } |
Statement I: P1 displays "Happy" 8 times.
Statement II: P2 displays "Happy" 12 times.
In the light of the above statements, choose the correct answer from the options given below
Match List I with List II
List I | List II | ||
System calls | Description | ||
A. | fork() | I. | Sends a signal from one process to another process |
B. | exec() | II. | Indicates termination of the current process |
C. | kill() | III. | Loads the specified program in the memory |
D. | exit() | IV. | Creates a child process |
Choose the correct answer from the options given below :
________ system call creates new process in Unix.
Identify the circumstances under which pre-emptive CPU scheduling is used:
(a) A process switches from Running state to Ready state
(b) A process switches from Waiting state to Ready state
(c) A process completes its execution
(d) A process switches from Ready to Waiting state
Choose the correct option: