Process and Communication in Operating Systems

0
106
Process and Communication in Operating Systems

Process and Communication

A process is a program in execution. A process needs CPU time, Memory, Files, and I/O devices, etc and these resources are allocated to it either when it is created or when it is executing. A process is not the same as a program. A process is more than program code. A process is an active entity as opposed to a program which is considered to be a passive entity. As we all know that a program is an algorithm expressed in some suitable notation, (e.g., programming language). Being passive, a program is only a part of the process.

A Process includes

  • The current value of Program Counter (PC)
  • Contents of the processor’s registers
  • Value of the variables
  • The process stack (SP) that typically contains temporary data such as subroutine parameter, return address, and temporary variables.
  • A data section that contains global variables.

A process is a unit of work in most systems. Operating System processes execute system code, while user processes execute user code. For creation and deletion of user and system processes, Operating System is responsible for the scheduling of processes, communication, synchronization and deadlock handling for processes.

Also Read: Services Provided By Operating Systems

Process State

A program by itself is not a process whereas a process is a program in execution that has its own program counter and internal states. A process has the following five states.

  1. New The process being
  2. Ready A process is ready to be executed and waiting for the CPU time.
  3. Running A process is said to be running if it has the CPU, that is, the process actually using the CPU at that particular instant.
  4. Waiting for A process is said to be blocked/waiting if it is waiting for some event to happen such that as an I/O completion before it can proceed.
  5. Terminate The process has finished execution.

Concurrent Processes

Many processes can be Multitasked on a CPU so that they can be executed concurrently. So executing processes in a time-shared Operating System is called concurrent processing.

Reasons for concurrent processing are

  • Physical Resource Sharing As hardware resources are limited, so we share them in a multi-user environment.
  • Logical Resource Sharing If many users are in need of sharing the same information i.e. a file etc, then we should provide an environment to allow concurrent access to such resources.
  • Speedup the Computation In order to make a task run faster, we can break it into subtasks and will execute all the subtasks at the same Such kind of speed can be achieved in Multiprocessing.
  • Modularity A system can be constructed in a modular design i.e. the functions of the system may be divided into different modules or dividing the system functions into separate processes.
  • Convenience An individual user may want to perform many tasks at one time i.e. Editing, Printing, and Compiling, etc.

Concurrent execution that requires cooperation among the processes also requires a mechanism for process synchronization and communication.

Process Control Block (PCB)

Also Read: Introduction to Operating System

Every process in the Operating System has its Process Task Control Block. A Process Control Block or PCB is basically a record containing different kinds of information about a specified process.

Different kinds of information contained in a PCB are

  • Process State Ready, Running or Waiting
  • Program Counter Indicating the address of the next instruction that will be executed for the process.
  • Accounting Information includes the amount of CPU and real time used. Similarly information about a job or process number, etc.

  • Registers depend upon the architecture of the Registers include accumulators, Index registers, stack pointers, and general purpose registers, etc.

In a computer, A Register is one of a small set of data holding places that are part of a computer microprocessor. Registers provide a place for passing data from one instruction to the next sequential instruction or to another program that the operating system has just given control to.

A register must be large enough to hold an instruction – for example, in a 32 -bit instruction computer, a register must be 32 bits in length. In some computer designs, there are smaller registers – for example, half-registers – for shorter instructions. Depending on the processor design and language rules, registers may be numbered or have arbitrary names.

  • Scheduling Information contains information about the priority of the process
  • Memory Management Information contains information about limit registers or Page tables
  • I/O Status contains information about the requests and usage of I/O devices

Independent and Cooperating Processes

The processes executing in the Operating System may be either Independent Processes or Cooperating Processes.

Also Read: Understanding Linux File System

Independent Process A process is Independent if it can not affect or be affected by the other processes executing in the system.

An Independent process has the following characteristics.

  • Its state is not shared in any way by the other process.
  • Its execution is deterministic i.e. the result of the execution completely depends upon the state of Input.
  • Its execution is reproducible, i.e. the result of execution will always be the same for that same Input
  • Its execution can be stopped and restarted without causing ill effects.

So, a process that does not share any data, etc with other processes is an Independent process.

Cooperating Process A process is cooperating if it can affect or be affected by the other processes executing in the system.

The cooperating process has the following characteristics.

  • State of the cooperating process is shared among other
  • The result of its execution cannot be predicted in advance, because it depends on the relative execution
  • The result of execution is non-deterministic as it will not always be the same for the same

So, a process that shares data with other processes is a Cooperating process. Cooperating processes may either directly share a logical address space (code and data) or may be allowed to share data through files.

Threads or Light Weight Processes are used in order to achieve the sharing of logical address space (code and data) in Cooperating processing.

Hierarchy of Process

A process can create several new processes. The process that creates processes is called the Parent process and the newly created processes are called children of that process. Similarly, the newly created processes can also create other processes, so we get a tree of processes.

Also Read: 15 Best Linux Applications that You MUST HAVE in 2019

Inter-Process Communication or IPC

Processes communicate with each other so, the issues related to the communication of processes is called Inter-Process Communication or IPC.

SHARE
Previous articleIntroduction to HTML -Part 1
Next articleRace Conditions
I am a Linux enthusiast still learning more about Linux and get my way around. I love writing articles and share what I know and Learn new things. I am also a security researcher and penetration tester.