Linux processes

L

One of the main tasks that the Kernel does is to allocate resources (RAM, CPU) to various applications. A process represents the elemental resource allocation unit in the system and runs in its own memory space. When a command is executed, a new process is created. The father of that process is the current shell. Process image is the program that runs and is loaded into RAM.

There are differences between a program and a process. The same program can generate several different processes. Each process that is running has certain rights on the system, namely the rights of the user who executed it (system user or person). A root process has root (total) rights, and the same process started by a normal user has the user’s (limited) rights. Exceptions are programs that have SUID or GUID set. They leave with the rights of the owner or the owner group and not the owner or the owner. Some commands are included in the shell and are not found as independent programs (executable files).
Example: cd, jobs, alias, umask, ulimit, echo. They do not create a new process when executed.

Process features:
1. The operating system uses the fork () system function to create new processes. The first step is to create a process identical to your parent (the same resources, rights, basically an identical copy of the parent). Subsequently, the newly created process “follows its own path”, it modifies the data received from the parent to perform its own task.
2. Each process has a parent, the one who created it. The exception makes the init process.
3. Processes are identified by a number unique for the whole system called PID (ProcessID).
4. The parent of each process is identified with a PPID (Parent Process ID).
5. The init process is the first to start the system buildup and has PID = 1. Init is also called the parent of all processes.
6. A process takes time from the moment it is created by the parent, and until the process executed by the process ends, and the outcome of the process is returned to the parent. At this point, the parent communicates to the Kernel to release the resources allocated to the process.

The states of a trial:
A process is in the following states from birth (fork ()) to its ending.
a) created
Represents the stage in which the process is created and awaits the scheduler’s permission for the ready state.
b) ready (waiting or runnable)
The process was loaded into memory and awaits CPU execution. There are several processes that are simultaneously in this state.
c) blocking (sleeping)
The process is blocked due to an inaccessible resource (file, semaphore, device). It is removed from the queue to be executed by the processor. If the resource is released, the process goes into the “ready” state.
d) running (active or executing)
The processor executes the process at this time. If it exceeds its slice (time) allotted for execution it will go back to the ready state.
e) terminated
A process enters this state either from the running state if the execution is complete or if a signal kills it. If it is not deleted from memory it becomes a zombie. If the process has children, they are taken over by the init.
f) suspended and waiting
They are the processes that have been removed from the main memory and taken to the swap.
g) suspended and blocked
Represents the processes found in the swap memory in the suspend state.

Attributes of a Process:
1. PID -> Process ID – the unique identifier of a process
2. PPID -> Parent Process ID – process parent identifier
3. UID -> User ID – The user ID under which the process runs
4. GUID -> Group ID – The group identifier under which the process runs
5. Priority

Process categories:
1. Parent
Each process can generate another process and become a parent. Apart from the process, each process has a parent.
2. Child
When the child process is running, the parent enters the sleeping state until the child finishes execution. If the child runs in the background, the parent comes in / stays ready.
3. Daemon
It is a process running in the background.
4. Orphan
It is the processes of whose parents have entered the terminated state before them. They are automatically taken over by the init, the father to all the processes.
5. Zombie (defunct)
Represents processes that have completed execution but are not deleted from deprecated tables. They cannot be terminated in conventional mode (using the kill command) but only by the parent or init process if the parent process finishes execution. Generally, zombies are allowed by the system because they do not consume resources.

Recent Posts

Archives

Categories