129

A program runs in user mode. To use hardware (files, network, new process) it makes a system call, which switches the CPU to kernel mode.

CategoryExamples (Linux)
Process controlfork(), exec(), exit(), wait()
File managementopen(), read(), write(), close()
Device managementioctl()
Informationgetpid(), time()
Communicationpipe(), socket(), shmget()
fork() C 10 lines
#include <unistd.h>
#include <stdio.h>

int main() {
    pid_t pid = fork();          // creates a child process
    if (pid == 0) printf("Child, pid = %d\n", getpid());
    else          printf("Parent, child pid = %d\n", pid);
    return 0;
}
// fork() returns 0 in the child and the child's pid in the parent