OS Process Synchronisation
OS Process Synchronisation
Topperworld.in
Process synchronisation
Overview:
• Processes Synchronization or Synchronization is the way by which
processes that share the same memory space are managed in an
operating system.
• It helps maintain the consistency of data by using variables or hardware
so that only one process can make changes to the shared memory at a
time.
• There are various solutions for the same such as semaphores, mutex
locks, synchronization hardware, etc
Process Synchronisation:
• An operating system is software that manages all applications on a
device and basically helps in the smooth functioning of our computer.
• Because of this reason, the operating system has to perform many
tasks, sometimes simultaneously.
• This isn't usually a problem unless these simultaneously occurring
processes use a common resource.
❖ For example, consider a bank that stores the account balance of each
customer in the same database.
• Now suppose you initially have x rupees in your account.
• Now, you take out some amount of money from your bank account,
and at the same time, someone tries to look at the amount of money
stored in your account.
• As you are taking out some money from your account, after the
transaction, the total balance left will be lower than x.
• But, the transaction takes time, and hence the person reads x as your
account balance which leads to inconsistent data.
• If in some way, we could make sure that only one process occurs at a
time, we could ensure consistent data.
©Topperworld
Operating System
✓ In the above image, if Process1 and Process2 happen at the same time,
user 2 will get the wrong account balance as Y because of Process1
being transacted when the balance is X.
✓ Inconsistency of data can occur when various processes share a
common resource in a system which is why there is a need for process
synchronization in the operating system.
Process Synchronization in OS Works?
Let us take a look at why exactly we need Process Synchronization.
❖ For example, If a process1 is trying to read the data present in a
memory location while another process2 is trying to change the data
present at the same location, there is a high chance that the data read
by the process1 will be incorrect.
©Topperworld
Operating System
©Topperworld
Operating System
©Topperworld
Operating System
©Topperworld