Process management in
Linux
There are generally two types of
processes that run on Linux. Interactive processes are those processes that are
invoked by a user and can interact with the user. Interactive processes can be
classified into foreground and background processes. The foreground process is
the process that you are currently interacting with, and is using the terminal
as its stdin (standard input) and stdout (standard output).
There are two kinds of execution
contexts in Linux. Process and lightweight processes. However, Linux makes no
distinction among these forms from scheduling point of view. Linux uses
lightweight processes to provide the features of a multithreaded application.
The Linux kernel use to store information about each process in the process
descriptor.
v Linux
Processes
Linux can manage the processes in
the system, each process is represented by a task_struct data structure (task
and process are terms that Linux uses interchangeably).
This means that the maximum
number of processes in the system is limited by the size of the task vector, by
default it has 512 entries. As processes are created, a new task_struct is
allocated from system memory and added into the task vector. To make it easy to
find, the current, running, process is pointed to by the current pointer.
Linux supports real time
processes. These processes have to react very quickly to external events (hence
the term ``real time'') and they are treated differently from normal user
processes by the scheduler. Although the task_struct data structure is quite
large and complex, but its fields can be divided into a number of functional
areas
v State
As a process executes it changes
state according to its circumstances. Linux processes have the following
states.
v Running
The process is either running (it
is the current process in the system) or it is ready to run (it is waiting to
be assigned to one the system CPU.
v Waiting
The process is waiting for an
event or for a resource. Linux differentiates between two types of waiting
process; interruptible and uninterruptible. Interruptible waiting processes can
be interrupted by signals whereas uninterruptible waiting processes are waiting
directly on hardware conditions and cannot be interrupted under any
circumstances.
v Stopped
The process has been stopped,
usually by receiving a signal. A process that is being debugged can be in a
stopped state.
v Scheduling
Information
The scheduler needs this
information in order to fairly decide which process in the system most deserves
to run,
v Identifiers
Every process in the system has a
process identifier. The process identifier is not an index into the task
vector, it is simply a number.
v Times
and Timers
The kernel keeps track of a
processes creation time as well as the CPU time that it consumes during its
lifetime. Each clock tick, the kernel updates the amount of time in jiffies
that the current process has spent in system and in user mode.
v Processor
Specific Context
A process could be thought of as
the sum total of the system's current state. Whenever a process is running it
is using the processor's registers, stacks and so on. This is the processes
context and, when a process is suspended, all of that CPU specific context must
be saved in the task_struct for the process. When a process is restarted by the
scheduler its context is restored from here.
No comments:
Post a Comment