What steps does the kernel take to return control to user space after the `fork()` system call? What are the return values for the parent and child processes?
The kernel prepares to return control to the user space. Before doing so, it sets the return values of fork for both the parent and child processes. The return value for the parent is the PID of the child, while for the child it is 0. The CPU state(including registers and program counter) is restored, and the CPU switches back to user mode, allowing both processes to continue execution.