Introduction Process
Introduction Process
Introduction Process
Introduction
• A process is compiled source code that is currently
running on the system.
• In the UNIX operating system, Processes can be defined as
independent streams of computation which compete over the
machine's resources.
• A PROCESS is a program that is loaded into memory and
ready to run.
• Each process is identified by a unique integer known as
a process identifier (PID).
• Every process has a parent process with PPID.
• The child process is often started by the parent process.
• PID is unique.
Cont..
• When a process is created, the kernel assigns it a unique
identification number called a PROCESS ID or PID
• To keep track of all the processes in the system, the
kernel maintains a PROCESS TABLE, indexed by PID,
containing one entry for each process.
• Along with the PID, each entry in the table contains the
information necessary to describe and manage the
process.
• A small Unix system can easily have over 100 processes
running at the same time.
Cont..
• Most processes are started automatically to perform tasks in
the background.
• On a large system, there can be hundreds or even thousands
of processes all needing to share the system’s resources:
processors, memory, I/O devices, network connections, and
so on.
• In order to manage such a complex workload, the kernel
provides a sophisticated scheduling service, referred to as
the SCHEDULER.
• At all times, the scheduler maintains a list of all the
processes waiting to execute.
• The scheduler chooses one process at a time, and gives it a
chance to run for a short interval called a TIME SLICE.
Process Control Block (PCB)
• As the operating system supports multi-programming, it
needs to keep track of all the processes.
• PCB is used to track the process’s execution status.
• When the process makes a transition from one state to
another, the operating system must update information in
the process’s PCB.
• Some of the attributes of a process stored in PCB are:
• Process Id: Every process will be given an id called
Process Id to uniquely identify that process from the
other processes.
• Process state: Each and every process has some states
associated with it at a particular instant of time. This is
denoted by process state. It can be ready, waiting,
running, etc.
• CPU scheduling information: Each process is executed
by using some process scheduling algorithms like FCSF,
Round-Robin, SJF, etc.
• I/O information: Each process needs some I/O devices
for their execution. So, the information about device
allocated and device need is crucial.
• Program counter – indicates that the address of the next
instruction to be executed.
• Memory management information – represents the
memory being used by a particular process.
Process States
• During execution, a process changes from one state to another
depending on its environment/circumstances.
• In Linux, a process has the following possible states:
• New- the process is being created.
• Running – the process is actually running (it is the current
process in the system)
• Waiting – in this state, a process is waiting for an event to
occur or for a system resource.
• Additionally, the kernel also differentiates between two types
of waiting processes;
• interruptible waiting processes – can be interrupted by signals
and uninterruptible waiting processes – are waiting directly on
hardware conditions and cannot be interrupted by any
event/signal.
• Ready – the process is waiting to be assigned to the
processor.
• Terminated– the process has finished execution.
CPU Scheduling
• CPU Scheduling is a process of determining which
process will own CPU for execution while another
process is on hold.
• The main task of CPU scheduling is to make sure that
whenever the CPU remains idle, the OS at least select
one of the processes available in the ready queue for
execution.
• The selection process will be carried out by the CPU
scheduler.
• It selects one of the processes in memory that are ready
for execution.
Important CPU scheduling
Terminologies
• Burst Time/Execution Time: It is a time required by the
process to complete execution. It is also called running
time.
• Arrival Time: when a process enters in a ready state
• Finish Time: when process complete and exit from a
system
• Multiprogramming: A number of programs which can
be present in memory at the same time.
• Jobs: It is a type of program without any kind of user
interaction.
CPU Scheduling Criteria
• A CPU scheduling algorithm tries to maximize and
minimize the following:
First Come First Serve
• Characteristics of FCFS method:
• Jobs are always executed on a first-come, first-serve
basis
• It is easy to implement and use.
• However, this method is poor in performance, and
the general wait time is quite high.
• Suppose the processes arrive in the order: P1, P2,P3.
• The Ghant chart for the schedule is:
• You can change the process priority using nice and Renice
utility.
• Nice command will launch a process with an user defined
scheduling priority.
• Renice command will modify the scheduling priority of a
running process.
• The process scheduling priority range is from -20 to 19. We
call this as nice value.
• A nice value of -20 represents highest priority, and a nice
value of 19 represent least priority for a process.
Cont…
• This guidelines are called niceness or nice value.
• The easiest way to get a quick picture of what the current
niceness priority on a process is to open up the top
processes with:
• Top command or Htop
ps command
• The current priority of a process can be displayed using ps
command.
• The “NI” column in the ps command output indicates the current
nice value (i.e priority) of a process.
• Example: test program called test.pl which will be used to
demonstrate nice and renice command.
• $ perl test.pl
• $ ps -fl -C "perl test.pl"
• F S UID PID PPID C PRI NI ADDR SZ WCHAN STIME TTY
TIME CMD
• 0 R bala 6884 6424 99 80 0 - 1556 - 13:45 pts/3 00:05:54 perl
test.pl.
• Now, let us stop the running program cmus with
command: $ kill -9 13829
Process Priority
Contd..
Contd..
Contd..
Contd..
End of the Lesson
Next: File System