0% found this document useful (0 votes)
25 views6 pages

Os Unit 1 Part 2

The document discusses process management concepts in operating systems including process states, process control blocks, threads, context switching, process creation and termination, and interprocess communication methods like shared memory and message passing.

Uploaded by

Raza Kashif
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)
25 views6 pages

Os Unit 1 Part 2

The document discusses process management concepts in operating systems including process states, process control blocks, threads, context switching, process creation and termination, and interprocess communication methods like shared memory and message passing.

Uploaded by

Raza Kashif
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/ 6

UNIT - 1

Process Management
Process Concept- Process Definition,
A Program does nothing unless its instructions are executed by a CPU.
A program in execution is called a process.

Process State
The process, from its creation to completion, passes through various states.
The state of a process is defined in part by the current activity of that process.
Each process may be in one of the following states during execution.

➢ New - The process is being created.

➢ Ready - The process has all the resources available that it needs to run, and waiting to be
assigned to a processor.

➢ Running – Instructions are being executed.

➢ Waiting - The process cannot run at the moment, because it is waiting for some resource to
become available or for some event to occur. For example, the process may be waiting for
keyboard input, disk access request.

➢ Terminated - The process has finished execution.

When the process is being created, it is there in the new state.


After the process is being created it is admitted and it comes to the ready state.
In the ready state, the process is ready to begin execution and it is waiting to be assigned to a
processor, so that it begins its execution.
The scheduler dispatches it to the processor and then it begins its execution.
When the instructions in the process is being executed that moment, the process is in the
running state.
After coming to the running state, there are three cases that can occur. They are

➢ The running process finished its execution and then it exits and goes to the terminated state.
➢ There can be an interrupt when the process was being executed. When this process was
being executed some other process with high priority comes, then this process was interrupted.
When it gets interrupted, it goes back to the Ready State again. Once the interrupt has been
handled this process again be dispatched and assigned to a processor and it can begin its
execution and go to the running state again.

➢ When the process is running it needs to wait for an input/output operation or an event. At
that time, it goes to the waiting state. Once the input/output operation or the event that it was
waiting for has been completed it goes to the ready state again.

Process Control Block


Each process is represented in the operating system by a process control Block (PCB). It is also
called Task control block.

Attributes which are stored in the PCB are


1. Process ID
When a process is created, a unique id is assigned to the process which is used for unique
identification of the process in the system.
2. Program counter
The counter indicates the address of the next instruction to be executed for this process.
3. Process State
The Process, from its creation to the completion, goes through various states which are new,
ready, running and waiting.
4. CPU registers
The registers vary in number and type, depending on the computer architecture. They include
accumulators, index registers, stack pointers and general-purpose registers. Along with the
program counter, this state information must be saved when an interrupt occurs, to allow the
process to be continued correctly afterward.
5. CPU-scheduling information.
This information includes process priority, pointers to scheduling queues, and any other
scheduling parameters.
6.Memory management information
It depends on the memory system used by the operating system. This may include information
such as the value of the base and limit registers, the page tables or the segment tables.
7.Accounting information
This information includes the amount of CPU and real time used, time limits, account number,
job or process numbers and so on.
8.I/O status information
This information includes the list of I/O devices allocated to the process, a list of open files,
and so on.

Threads
Threads in Operating System A thread is a single sequential flow of execution of tasks of a
process.
It is a basic unit of CPU utilization.
Components of Thread A thread has the following three components:
1. Program Counter
2. Register Set
3. Stack space

Context Switch
The Context switching is a technique or method used by the operating system to switch a
process from one state to another to execute its function using CPUs in the system.
Operations on Processes- Creation and Termination of Processes
Process Creation
A process may be created in the system for different operations.
Some of the events that lead to process creation are as follows −

• User request for process creation


• System Initialization
• Batch job initialization
• Execution of a process creation system call by a running process
A process may be created by another process using fork(). The creating process is called the
parent process and the created process is the child process. A child process can have only one
parent but a parent process may have many children. Both the parent and child processes have
the same memory image, open files and environment strings. However, they have distinct
address spaces.

Process Termination
Process termination occurs when the process is terminated.
The exit() system call is used by most operating systems for process termination.
Some of the causes of process termination are as follows −

• A process may be terminated after its execution is naturally completed. This


process leaves the processor and releases all its resources.
• A child process may be terminated if its parent process requests for its
termination.
• A process can be terminated if it tries to use a resource that it is not allowed to.
For example - A process can be terminated for trying to write into a read only
file.
• If an I/O failure occurs for a process, it can be terminated. For example - If a
process requires the printer and it is not working, then the process will be
terminated.
• In most cases, if a parent process is terminated then its child processes are also
terminated. This is done because the child process cannot exist without the
parent process.
• If a process requires more memory than is currently available in the system, then
it is terminated because of memory scarcity.
Inter process communication (IPC)- Definition
"Inter-process communication is used for exchanging useful information between numerous
threads in one or more processes (or programs)."

Need for Inter process Communication


1.Information Sharing
Cooperating processes can be used to share information between various processes. It could
involve having access to the same files. A technique is necessary so that the processes may
access the files concurrently.
2. Modularity
Modularity refers to the division of complex tasks into smaller subtasks. Different cooperating
processes can complete these smaller subtasks. As a result, the required tasks are completed
more quickly and efficiently.
3. Computation Speedup
Cooperating processes can be used to accomplish subtasks of a single task simultaneously. It
improves computation speed by allowing the task to be accomplished faster. Although, it is
only possible if the system contains several processing elements.
4. Convenience
There are multiple tasks that a user requires to perform, such as printing, compiling, editing,
etc. It is more convenient if these activities may be managed through cooperating processes.

IPC Implementation Methods- Shared Memory and Message Passing

Shared Memory Message Passing

It is one of the region for data communication Mainly the message passing is used for
communication.

It is used for communication between single It is used in distributed environments where the
processor and multiprocessor systems where communicating processes are present on remote
the processes that are to be communicated machines which are connected with the help of a
present on the same machine and they are network.
sharing common address space.

The shared memory code that has to be read or Here no code is required because the message
write the data that should be written explicitly passing facility provides a mechanism for
by the application programmer. communication and synchronization of actions
Shared Memory Message Passing

that are performed by the communicating


processes.

It is going to provide a maximum speed of Message passing is a time consuming process


computations because the communication is because it is implemented through kernel (system
done with the help of shared memory so calls).
system calls are used to establish the shared
memory.

In shared memory make sure that the processes Message passing is useful for sharing small
are not writing to the same location amounts of data so that conflicts need not occur.
simultaneously.

It follows a faster communication strategy In message passing the communication is slower


when compared to message passing technique. when compared to shared memory technique.

Given below is the structure of shared memory Given below is the structure of message passing
system − system −

You might also like