In a Unix-like operating system, the interaction between user applications and the kernel is facilitated through system calls. System calls provide a controlled interface for user applications to request services from the kernel, such as creating process, managing memory, or handling I/O operations.
When a process calls fork, the following sequence of events occur:-
1. System Call Invocation:-
The process involves the fork function, which is part of the C standard library. The fork function triggers a software interrupt or a system call instruction.
2. Switch to Kernel Mode:-
The CPU switches from user mode to kernel mode. This switch is necessary because direct access to hardware and critical system resources is restricted to kernel mode to ensure system stability and security. The current state of the process is saved.
3. System Call Handler:-
The system call instruction triggers a predefined entry point in the kernel, known as the system call handler.