Skip to main content

  | मौसम…

411 समाचार
Public archive edition · Attributed source reporting with original dates · AI drafts are excluded

411 REFERENCE · Wikibooks

The Linux Kernel/Processes

Reference material by Wikibooks contributors. This retains its source identity and is not 411 news reporting.

== Processes == Process is a running user space program. Kernel starts the first process /sbin/init in function run_init_process using kernel_execve. Processes occupy system resources, like memory, CPU time. System calls sys_fork and sys_execve are used to create new processes from user space. The process exit with an sys_exit system call. Linux inherits from Unix its basic process management system calls (⚲ API ↪ ⚙️ implementations): 2 fork ↪ kernel_clone creates a new process by Prototype_pattern duplicating the process invoking it. 2 _exit ↪ do_exit terminates the calling process "immediately". Any open file descriptors belonging to the process are closed. 2 wait ↪ kernel_waitid suspends the execution of the calling process until one of its children processes terminates. Linux enhances the traditional Unix process API with its own system calls 2 clone. Clone creates a child process that may share parts of its execution context with the parent. It is often used to implement threads (though programmers will typically use a higher-level interface such as 7 pthreads, implemented on top of clone). PID - Process identifier defined as pid_t is unique sequential number. 1 ps -A lists current processes. ⚲ API unistd.h sys/types.h sys/wait.h ⚙️ Internals task_struct pid_type kernel/fork.c – process creation and cloning syscalls: 2 set_tid_address – set pointer to thread ID 2 fork – create a child process 2 vfork – create a child process and block parent 2 clone – create a child process 2 unshare – disassociate parts of the process execution context kernel/sys.c – system and process operations syscalls: 2 prctl – operations on a process or thread kernel/pid.c – PID allocation and management syscalls: 2 pidfd_open – obtain a file descriptor that refers to a process (since 5.3) 2 pidfd_send_signal – send signal via pidfd, race-free (since 5.1) 2 pidfd_getfd – obtain a duplicate of another process's file descriptor (since 5.6) kernel/exit.c – process termination syscalls: 2 exit – terminate the calling process 2 exit_group – exit all threads in a process 2 waitid – wait for process to change state 2 waitpid – wait for process to change state fs/exec.c – program execution (execve) 2 ptrace ↪ kernel/ptrace.c – process tracing, used by 1 strace and debuggers 📖 References fork (system call) exit (system call) wait (system call) exec (system call)