Operating System: Question Set – 11
What happens when you type a command in a shell?
- The shell creates a new process using fork().
- The child process executes the command using exec().
- The parent process waits for the child process to complete using wait().
What are orphan processes?
When a parent process ends without waiting for its child processes, this is known as an orphan process. Orphan processes are usually adopted by the OS’s init process.
What is priority inversion?
When a higher-priority process waits for a resource that a lower-priority process holds while it waits for another higher-priority process to execute, this is known as priority inversion.
What is a lightweight process?
A thread is referred to as a lightweight process. Although they function independently, threads in a process share the same memory and resources.
How does the OS handle a process that exceeds its time slice?
The OS switches the context to return the process to the ready queue so that another process can run in a preemptive multitasking system.
What is the difference between blocking and non-blocking system calls?
- Blocking system calls: Cause the process to wait until the operation completes (e.g., read()).
- Non-blocking system calls: Allow the process to continue execution without waiting for the operation to complete.
What is the difference between segmentation fault and stack overflow?
- A segmentation fault occurs when a process tries to access memory that it is not allowed to access.
- A stack overflow happens when the stack exceeds its memory limit, typically due to deep or infinite recursion.
What is process aging?
Aging is a scheduling strategy that progressively raises the priority of waiting operations in order to avoid famine.
What is swap space?
When the actual RAM is full, the system’s virtual memory can be expanded using swap space, a section of the disk.
What is the difference between thread-safe and reentrant code?
- Thread-safe code can be safely used by multiple threads at the same time.
- Reentrant code can be interrupted and safely called again before the previous executions are complete.
What happens if a process in the ready state does not get CPU time?
It remains in the ready queue until the scheduler assigns CPU time to it.
What is a multithreaded process?
Parallelism is made possible by a multithreaded process, which consists of several threads of execution within one process. Although they run separately, threads share resources like memory.
What is the difference between shared memory and message passing in IPC?
- Shared Memory: Processes communicate by reading/writing to a shared section of memory.
- Message Passing: Processes communicate by exchanging messages, typically through system calls like send() and receive().
What is the role of the dispatcher in process scheduling?
The dispatcher is responsible for:
- Switching context.
- Switching to user mode.
- Jumping to the proper location in the program to start execution.