Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
325 views

Process in Operating System

The document discusses processes in an operating system. It defines a process as a program in execution. Processes can be in one of three states: running, ready, or blocked. The document describes process state transitions and how processes move between states. It also discusses the process control block (PCB), which stores important information about each process, and common operations on processes like creating, destroying, suspending, and resuming processes. Finally, it covers interrupt processing and context switching, which allow multiple processes to share a CPU.
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
325 views

Process in Operating System

The document discusses processes in an operating system. It defines a process as a program in execution. Processes can be in one of three states: running, ready, or blocked. The document describes process state transitions and how processes move between states. It also discusses the process control block (PCB), which stores important information about each process, and common operations on processes like creating, destroying, suspending, and resuming processes. Finally, it covers interrupt processing and context switching, which allow multiple processes to share a CPU.
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

Operating System

Process in Operating System


Definition of a Process: A process is a “program in execution”

A program is an inanimate entity; only when a processor “breathes life” into it does it become
the “active” entity.

Process States:

1. Running – if it is currently has the CPU


2. Ready – if it could use a CPU if one is available
3. Blocked – if it is waiting for some events to happen before it can be processed.
Example – I/O completion.

Process Transition:

Fig. 1. Process state transitions

When a job is admitted to the system, a corresponding process is created and normally
inserted at the back of the ready list.

The process gradually moves to the head of the ready list as the processes before it complete
their turns at using the CPU. When the process reaches the head of the list, and when the
CPU becomes available, the process is given the CPU and is said to make a state transition
from ready state to the running state (Fig. 1).

The assignment of the CPU to the first process on the ready list is called dispatching, and is
performed by a system entity called the dispatcher.

To prevent any one process from monopolizing the system, either accidentally or maliciously,
the operating system sets a hardware interrupting clock (or interval timer) to allow this user
to run for a specific time interval or quantum. If the process does not voluntarily relinquish
the CPU before the time interval expires, the interrupting clock generates an interrupt,
causing the operating system to regain control. The operating system then makes the
previously “running” process “ready”, and makes the first process on the ready list running.

1
Operating System

If a running process initiates an input/output operation before its quantum expires, the
running process voluntarily relinquishes the CPU (i.e., the process blocks itself pending the
completion of the input/output operation).

The only other allowable state transition in our three-state model occurs when an input/
output operation (or some other event the process is waiting for) completes. The process
makes the transition from the blocked state to the ready state.

Note that only state transition initiated by user process itself is block – the other three
transitions are initiated by entities external to the process.

The Process Control Block (PCB) or Process Descriptor

The PCB is a data structure containing certain important information about the process
including:

 the current state of the process


 unique identification of the process
 a pointer to the process-'s parent (i.e., the process that created this process)
 pointers to the process's child processes (i.e., processes created by this process)
 the process's priority
 pointers to locate the process's memory
 pointers to allocated resources
 a register save area
 the processor it is running on (in multiprocessor system)

The PCB is a central store of information that allows the operating system to locate all key
information about a process. When the operating system switches the attention of the CPU
among the various active processes, it uses the save areas in the PCB to hold the information
it needs to restart each process when the process next gets the CPU.

Operations on Processes:

Systems that manage processes must be able to perform certain operations on and with
processes. These include create a process, destroy a process , suspend a process, resume a
process, change priority of a process, block a process, wakeup a process, dispatch a
process, enable a process to communicate with another process (called interprocess
communication)

Creating a process involves many operations including, name the process, insert it in the
system's known processes list (or process table), determine the process's initial priority, create
the process control block, allocate the process's initial resources

A process may spawn a new process. If it does, the creating process is called the parent
process and the created process is called the child process. Only one parent is needed to
create a child. Such creation yields a hierarchical process structure.

2
Operating System

Destroying a process involves obliterating it from the system. Its resources are returned to the
system, it is purged from any system lists or tables, and its process control block is erased.

Suspend and Resume a Process:

When a process is suspended, a part of the process or the entire process is moved from main
memory to disk. This is also called Swapping.

Thus, Swapping is an I/O operation but disk I/O is faster than peripheral I/O.

Fig. 2. Process state transitions with suspend and resume.

Characteristics of a suspended process:

1. The process is not immediately available for execution.


2. The process may or may not be waiting for an event.
3. The process was placed in a suspended state by an agent: either itself, a parent
process, or the operating system, for the purpose of preventing its execution.
4. The process may not be removed from this state until the agent explicitly orders the
removal.

Reasons for process suspension:

 Swapping - the operating system needs to release sufficient main memory to bring in
a process that is ready to execute.

3
Operating System

 Other OS reason - the operating system may suspend a background or utility process
or a process that is suspected of causing a problem.
 Interactive user request - a user may wish to suspend a background or utility process
or a process that is suspected of causing a problem.
 Timing - a process may be executed periodically and may be suspended while
waiting for the next time interval.
 Parent process request - a parent process may wish to suspend execution of a
descendent to examine or modify the suspended process, or to coordinate the activity
of various decedents.

Interrupt Processing:

On a computer system, an interrupt is an event that alters the sequence in which a processor
executes instructions. It is generated by the hardware of the computer system. When an
interrupt occurs

 The operating system gains control (i.e., the hardware passes control to the operating
system).
 The operating system saves the state of the interrupted process. In many systems this
information is stored in the interrupted process's process control block.
 The operating system analyzes the interrupt and passes control to the appropriate
routine to handle the interrupt; on many of today's systems this is handled
automatically by the hardware.
 The interrupt handler routine processes the interrupt.
 The state of the interrupted process (or some other "next process") is restored.
 The interrupted process (or some other "next process") executes.

An interrupt may be specifically initiated by a running process (in which case it is often
called a trap and said to be synchronous with the operation of the process), or it may be
caused by some event that may or may not be related to the running process (in which case it
is said to be asynchronous with the operation of the process).

Advantage of Interrupt: A key advantage to the interrupt concept is that it provides a low-
overhead means of gaining the attention of the CPU. This eliminates the need for the CPU to
remain busy polling to see if devices require its attention.

Interrupt Classes: There are six interrupt classes:

1. SVC (supervisor call) interrupts: Initiated by a running process on request from a


user. A user may not arbitrarily enter the operating system; rather the user must
request a service through an SVC.
2. I/O interrupts: These are initiated by the input/output hardware.
3. External interrupts: These interrupts are caused by various reasons. (example:
interrupt clock, pressing interrupt key on consol window by user, signal from an
external CPU in a multi-processor environment)

4
Operating System

4. Restart interrupts: These occur when the operator presses the console's restart button,
or when a restart SIGP (signal processor) instruction arrives from another processor
on a multiprocessor system.
5. Program check interrupts: These are caused by a wide range of problems that may
occur as a program's machine language instructions are executed. These problems
include division by zero, arithmetic overflow or underflow, data (being operated
upon) is in the wrong format, attempt to execute an invalid operation code, attempt to
reference a memory location beyond the limits of real memory etc.
6. Machine Check Interrupt: This interrupt takes place due to a malfunctioning
hardware.

Context Switching

A context switch is the mechanism to store and restore the state or context of a CPU in
Process Control block so that a process execution can be resumed from the same point at a
later time. Using this technique, a context switcher enables multiple processes to share a
single CPU. Context switching is an essential part of a multitasking operating system
features.

This mechanism is used in handling interrupts and resuming the general processes after the
interrupt is handled.

Nucleus of an Operating System:

 All of the operations involving processes are controlled by a portion of the operating
system variously called its nucleus, core, or kernel.
 The nucleus normally represents only a small portion of the code of what is
commonly thought to be the entire operating system, but it is among the most
intensively used code. For this reason, the nucleus ordinarily remains in primary
storage while other portions of the operating system are shuttled to and from
secondary storage as needed.
 One of the most important functions included in the nucleus is interrupt processing.
 In large, multiuser systems, a constant blizzard of interrupts is directed at the
processor. Rapid response to these interrupts is essential to keeping the resources of
the system well utilized, and to providing acceptable response times to interactive
users.
 The nucleus disables interrupts while it is responding to an interrupt; interrupts are
again enabled after the processing of an interrupt is complete.

You might also like