Question 61
HardHow many processes exist in total (including the original) after this code runs?
fork();
fork() && fork();
- A.
Popular companies
Prepare company by company
Hiring pattern, syllabus, past questions and mocks for each company.
All companiesPractice by subject
Operating Systems
How many processes exist in total (including the original) after this code runs?
fork();
fork() && fork();
6
4
8
5
Sign up free to see the answer and a step-by-step explanation.
How many times is 'X' printed?
for (int i = 0; i < 3; i++)
fork();
printf("X\n");
6
8
7
3
Sign up free to see the answer and a step-by-step explanation.
A parent process forks a child and then exits without calling wait(), while the child keeps running. What does the child become?
It is terminated at once
A daemon that must be killed
A zombie
An orphan, adopted by init (or systemd)
Sign up free to see the answer and a step-by-step explanation.
Which event causes a switch from user mode to kernel mode?
A system call, an exception or an interrupt
Only a page hit
Printing to a buffer in user memory
Only a function call in user code
Sign up free to see the answer and a step-by-step explanation.
Why is the system-call interface implemented with a trap instruction rather than an ordinary function call?
Traps avoid using the stack
It switches the CPU to kernel mode in a controlled way, entering only at kernel-chosen addresses
Function calls can't pass arguments
Traps are faster than function calls
Sign up free to see the answer and a step-by-step explanation.
What is the main advantage of a microkernel over a monolithic kernel?
It has more code inside the kernel
It is always faster
A fault in a service such as a driver need not crash the whole system, since services run in user space
It needs no inter-process communication
Sign up free to see the answer and a step-by-step explanation.
In a Linux system, what does the call exec() do to the calling process's PID?
It gives the process a new PID
It creates a child with a new PID
It sets the PID to 0
It keeps the same PID while replacing the program
Sign up free to see the answer and a step-by-step explanation.
What does a hypervisor of Type 1 (bare-metal) run on?
Only inside containers
On top of a host operating system
Inside a web browser
Directly on the hardware, with guest operating systems above it
Sign up free to see the answer and a step-by-step explanation.
How do containers differ from virtual machines?
VMs cannot run Linux
Containers share the host's kernel; each VM runs its own full guest OS
Containers include a separate kernel each
Containers need special hardware
Sign up free to see the answer and a step-by-step explanation.
What is the role of the bootloader?
To manage virtual memory
To load the operating system kernel into memory and start it
To format the disk
To schedule processes
Sign up free to see the answer and a step-by-step explanation.