Home » Operating Systems

Process synchronization in Operating System and Inter process communication

Learn: In this article we are going to discuss about the process synchronization in operating system and inter process communication. How can the operating system synchronize processes? What are the different solutions and algorithm used by the operating system in synchronizing processes of the operating system? What is inter process communication? What are the different methods used to maintain intercommunication?
Submitted by Amit Shukla, on August 01, 2017

Process Synchronization

Process synchronization is the task of synchronizing the execution of processes in such a manner that no two processes have access to the same shared data and resource. In a multi process system when multiple processes are running simultaneously, then they may attempt to gain the access of same shared data and resource at a time. This can lead in inconsistency of shared data. That is the changes made by one process may not be reflected when other process accessed the same shared data. In order to avoid these types of inconsistency of data the processes should be synchronized with each other.

One of the important concepts related to process synchronization is that of the critical selection problem. Each process contains a set of code called critical section through which a specific task, such as writing some data to file or changing the value of global variable, is performed. To ensure that only one single process should be entering in critical section at a specific instant of time, the process needs to be coordinated with other by sending requests for entering the critical section. When a process is in its critical section, then no other process is allowed to enter in critical section during the time period when one process is in a critical section.

The following are the different solutions or algorithms used in synchronizing the different processes of any operating system:

1. Peterson’s solution

Peterson’s solution is one of the famous solutions to critical section problems. This algorithm is created by a computer scientist Peterson. Peterson’s solution is solution to the critical section problem involving two processes. Peterson’s solution states that when a process is executing in its critical state, then the other process executes the rest of code and vice versa. This insures that only one process is in the critical section at a particular instant of time.

2. Locking solution

Locking solution is another solution to critical problems in which a process acquires a lock before entering its critical section. When a process finishes its executing process in the critical section, then it releases the lock. Then the lock is available for any other process that wants to execute its critical section. The locking mechanism also ensures that only one process is in the critical section at a particular instant of time.

3. Semaphore solution

Semaphore solutions are another algorithm or solution to the critical section problem. It is basically a synchronization tool in which the value of an integer variable called semaphore is retrieved and set using wait and signal operations. Based on the value of the semaphore variable, a process is allowed to enter its critical section.

Inter Process Communication

Inter process communication is the method of communication which is used to make communication between process through which processes interact with each other for gaining access of shared data and resources.

There are mainly two methods of inter process communication:

  1. Shared memory
  2. Message passing

1) Shared memory

In the shared memory, a part of memory is shared between the processes. A process can write the data that it wants to share with other process. Similarly, another process can read the data that have been written by the other process.

The following figure shows the shared memory method of inter process communication.

shared memory method of inter process communication

2) Message passing

In the message passing method, a process sends a message to another process for communication. This method allows the sharing of data between processes in the form of messages.

The following figure shows the message passing method of inter process communication.

message passing method of inter process communication




Comments and Discussions

Ad: Are you a blogger? Join our Blogging forum.



Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing » Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates

© https://www.includehelp.com some rights reserved.