Dive into the intricate world of process synchronization in operating systems! This video covers everything you need to know about how processes coordinate and synchronize their actions to ensure data consistency and avoid conflicts.

What You'll Learn:

The importance of process synchronization in OS.
Key concepts like critical sections, race conditions, and mutual exclusion.
Various synchronization mechanisms and techniques.
Real-world examples to help you understand these concepts better.

Whether you're a student, a professional, or just a tech enthusiast, this video breaks down complex concepts into easily understandable segments.

Like, Share, and Subscribe:
If you found this video helpful, please give it a thumbs up, share it with your friends, and subscribe to our channel for more insightful content.


Follow Me On Social Media -
Facebook - https://www.facebook.com/asad.nomanee

Software Engineering Full Course Link :https://www.youtube.com/playlist?list=PLncy2sD7w4YqcWltmTBXgCiyLB9llT703

Theory Of Computation Full Course Link : https://youtube.com/playlist?list=PLncy2sD7w4YqBniaSEkOtzcZa3UNtWpMF

Operating System Full Course Link:
https://youtube.com/playlist?list=PLncy2sD7w4Yr3ZbiP_ipAjgjDRn86N_tT

Computer Networks | Data Communication | Communication Engineering Full Course Link:
https://youtube.com/playlist?list=PLncy2sD7w4YpQ1xYzwuf8-IFWlks7V6uo

Database Management System Full Course Link:
https://youtube.com/playlist?list=PLncy2sD7w4Yq3p7qS9UjMrRXrS2_FgUrA

---------------------------------------------
#Chapter3
#ProcessSynchronization : There are two types of process
1. Cooperative process:
• In this kind of process execution of one process will cause some changes on other process.
• This happens because they may have something in common or share something; it could be variable, memory or buffer, code, resources (CPU, printer, and scanner).
2. Independent process:
• In this kind of process execution of one process does not affect any other process, because they do not share anything or have anything in common.
Let’s see an example and try to understand the concept the process synchronization. Here both the programs share a variable named shared and in this case we are talking about uni-processor system.
int shared = 5;
P1
int x = shared;
x++;
sleep(1);
shared = x;
P2
int y = shared;
y--;
sleep(1);
shared = y;
• As mentioned earlier we are talking about uniprocessor system.
• We will execute P1 program first, you can also execute P2 first.
• When we execute the P1 program the value of shared get sorted/copied into a variable x.
• Then value of x is incremented by one and it becomes 6 from 5.
• For 1 second P1 process will be stop executing (due to sleep(1);) command, when P1 get paused CPU will not pause rather CPU will start executing P2 (CPU will perform context switching by saving the details of P1 in PCB which stands for process control block.)
• Context switching is possible in this case because there is a process in parallel.
• Now, P2 will start executing and value of shared variable which is 5 gets stored in a variable y.
• Now the value of y will become 4 after executing the command y--.
• After that P2 will also get sleep for 1 second because of the same reason that was present in the P1 program and is sleep(1)
• Now, CPU will start executing P1 from we’re it was paused.
• The value of x variable is 6 so according to the code we will load the value in shared variable.
• Now the value in shared variable is 6. And the program P1 will get terminate.
• Now again P2 will start executing from the sate it was paused.
• Here the value of y is 4 and the same will get load in the shared variable.
• Now the value of shared variable is 4.
• But this is wrong answer because we are adding 1 in a value and subtracting 1 from that so the value of variable should not change but here the value of variable is changing.
• This is because both the processes are sharing something so they are cooperative processes but they are not synchronized if they were synchronized then this problem will not occur.
• This problem is known as Race condition, and that’s why we need process synchronization.
So, in conclusion we can say that whenever two or more cooperative process run then a problem will occur known as race condition.


#RaceCondition
A Race Condition typically occurs when two or more threads try to read, write and possibly make the decisions based on the memory that they are accessing concurrently.
#CriticalSection
The regions of a program that try to access shared resources and may cause race conditions are called critical section. To avoid race condition among the processes, we need to assure that only one process at a time can execute within the critical section.


#ProcessSynchronization
#OperatingSystem #OS #asadnomanee #banglalecture #CSE
#Lecturelia #MBSTU #MBSTU_CSE
#lecturelia #banglatutorial #bangla