Process

From Rice Wiki
Revision as of 21:48, 19 June 2024 by Rice (talk | contribs) (Created page with "Category:Computer Science In Linux, a '''program''' is a passive set of machine code instructions and data stored in an executable image. A '''process''' can be thought of as this passive program in action. Processes are independent separate tasks. If one process crashed, it will not affect any other processes. The kernel manages resource allocation (such as the CPU) between different processes. This is done by the scheduler. == Process composition == Represen...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

In Linux, a program is a passive set of machine code instructions and data stored in an executable image. A process can be thought of as this passive program in action.

Processes are independent separate tasks. If one process crashed, it will not affect any other processes.

The kernel manages resource allocation (such as the CPU) between different processes. This is done by the scheduler.

Process composition

Representing the execution of a program, a process includes the state of the program first and foremost. This includes

Beyond the state of the program, each process is allocated its own process identifier (PID) and virtual memory among other things.

Lifetime of a process

Init process

When the computer starts, the only thing the kernel execute in the user space is a init command (shown with ps -f 1). This process is allocated a PID of 1 and is the only process with no parent process.

Creating a process

In contrast to the init process, all other processes are created by parent processes. This is done with fork and exec. First, the shell will run fork to create a cloned process from the current process, and exec replaces the program in the cloned process with another program.

Sources