0% found this document useful (0 votes)
4 views43 pages

unit 2 operating system

A process is an executing instance of a program, which can be divided into four sections: text, stack, data, and heap. Processes go through various states such as NEW, READY, RUNNING, WAITING, and TERMINATED, and are managed by a Process Control Block (PCB) that contains essential information for tracking the process. Each process is assigned a unique Process ID (PID) in Unix-like operating systems, and the operating system maps logical addresses to physical addresses during memory allocation.

Uploaded by

Akhilesh kumar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views43 pages

unit 2 operating system

A process is an executing instance of a program, which can be divided into four sections: text, stack, data, and heap. Processes go through various states such as NEW, READY, RUNNING, WAITING, and TERMINATED, and are managed by a Process Control Block (PCB) that contains essential information for tracking the process. Each process is assigned a unique Process ID (PID) in Unix-like operating systems, and the operating system maps logical addresses to physical addresses during memory allocation.

Uploaded by

Akhilesh kumar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 43

Process Concept

Program vs. Process


A process is a program in execution. For example, when we write a program in
C or C++ and compile it, the compiler creates binary code. The original code
and binary code are both programs. When we actually run the binary code, it
becomes a process.
A process is an ‘active’ entity, as opposed to a program, which is considered to
be a ‘passive’ entity. A single program can create many processes when run
multiple times; for example, when we open a .exe or binary file multiple times,
multiple instances begin (multiple processes are created).

Process in memory
When a program is loaded into the memory and it becomes a process, it can be
divided into four sections ─ stack, heap, text and data. The following image
shows a simplified layout of a process inside main memory −

 Text Section: A Process, sometimes known as the Text Section, also


includes the current activity represented by the value of the Program
Counter.
 Stack: The Stack contains the temporary data, such as function
parameters, returns addresses, and local variables.
 Data Section: Contains the global variable.
 Heap Section: Dynamically allocated memory to process during its run
time.

Process Life Cycle or Process states

When a process executes, it passes through different states. These stages may
differ in different operating systems, and the names of these states are also not
standardized.

 NEW- The process is being created.


 READY- The process is waiting to be assigned to a processor.

 RUNNING- Instructions are being executed.

 WAITING- The process is waiting for some event to occur (such as an I/


O completion or reception of a signal).

 TERMINATED- The process has finished execution.


Process Control Block (PCB) or Task control block

A Process Control Block is a data structure maintained by the Operating System


for every process. The PCB is identified by an integer process ID (PID). A PCB
keeps all the information needed to keep track of a process as listed below:

 Process State: It can be running, waiting etc.


 Process ID and the parent process ID.

 CPU registers and Program Counter. Program Counter holds the


address of the next instruction to be executed for that process.

 CPU Scheduling information: Such as priority information and pointers


to scheduling queues.

 Memory Management information: For example, page tables or


segment tables.

 Accounting information: The User and kernel CPU time consumed,


account numbers, limits, etc.

 I/O Status information: Devices allocated, open file tables, etc.


 All of the above attributes of a process are also known as the context of
the process.

 The architecture of a PCB is completely dependent on Operating System


and may contain different information in different operating systems.

Process Address space


 An address space is a range of valid addresses in memory that are
available for a program or process. That is, it is the memory that a
program or process can access. The memory can be either physical or
virtual and is used for executing instructions and storing data.

 The process address space is the set of logical addresses that a process
references in its code. For example, when 32-bit addressing is in use,
addresses can range from 0 to 0x7fffffff; that is, 2^31 possible numbers,
for a total theoretical size of 2 gigabytes.

The operating system takes care of mapping the logical addresses to physical
addresses at the time of memory allocation to the program. There are three
types of addresses used in a program before and after memory is allocated :

 Symbolic addresses

The addresses used in a source code. The variable names, constants, and
instruction labels are the basic elements of the symbolic address space.

 Relative addresses

At the time of compilation, a compiler converts symbolic addresses into


relative addresses.

 Physical addresses

The loader generates these addresses at the time when a program is loaded
into main memory.
The set of all logical addresses generated by a program is referred to as
a logical address space. The set of all physical addresses corresponding to
these logical addresses is referred to as a physical address space.

Process Identification Information


A PID (i.e., process identification number) is an identification number that is
automatically assigned to each process when it is created on a Unix-
like operating system. A process is an executing (i.e., running) instance of a
program. Each process is guaranteed a unique PID, which is always a non-
negative integer.
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner

You might also like