Please enable JavaScript.
Coggle requires JavaScript to display documents.
Processes and Signals (Process Structure (Each process is allocated a…
Processes and Signals
Process Structure
Each process is allocated a unique number called a process identifier PID. The PID 1 is reserved for the init process.
-
Not everything can be shared. The variables used for each process are unique for each process. Each process has its own stack space. Also the program counter is distinct for each process.
Process Scheduling
Linux kernel uses a process scheduler to decide which process will receive the nest time slice. It does this using a process priority algorithm.
Process with high priority run more often and low priority processes run less frequently. Processes cant overrun their designated time slice.
The high priority processes are called nice. You can modify the priority of a process with nice and renice commands.
Signals
Is an event generated by the UNIX and Linus systems in response to some condition, a process may in turn take some action when it received one.
They are raised by some error. They are generated by the shell and terminal handlers to cause interrupts and can also be used to pass information from one process to another.
If a process receives a signal without arranging to receive it then the process is terminated. A core dump file is created.
Sending Signals
A process can send a signal to another process by using kill. This will only succeed if the user has the permission, the process can only send signals to processes owned by the same user.
Kill will fail and return -1 if the signal given is not valid, if it doesn't have permission, or if the specified process doesn't exist.
The alarm call schedules the delivery of a SIGALRM signal in seconds. Calling alarm before the signal is received will reschedule the alarm.
Signal Sets
The header file signal.h defines the type sigset_t and functions used to manipulate sets of signals. These sets are used in sigaction and other functions to modify process behavior on receipt of signals.
These functions perform the operations suggested by their names, sigemptyset initializes a signal set to be empty, sigfillset initializes a signal set to contain all defined signals. They all return 0 if successful and -1 on error.
The sigismember determines whether the given signal is a member of a signal set. Returns 1 if is member and 0 if it isn't.
Process
An address space with one or more threads executing within that address space, and the required system resources for those threads.
Consist of program code, data, variables, open files, and an environment.
Zombie Processes
When a child process terminates and association with the parent survives until the parent terminates or calls wait. When this happens the child process is no longer active but it is still in the system, this is a zombie process.
If the parent terminates abnormally then the child automatically gets the PPID 1 (init). In this case the zombie process will remain in the system until it is collected by the init process.