0% found this document useful (0 votes)
9 views

Process Syncronization

The document discusses process synchronization techniques like shared memory, message passing, and file sharing. It describes problems that can occur with concurrent access like race conditions and deadlocks. Common synchronization methods like semaphores, mutexes, and monitors are explained.

Uploaded by

Sameer Najam
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views

Process Syncronization

The document discusses process synchronization techniques like shared memory, message passing, and file sharing. It describes problems that can occur with concurrent access like race conditions and deadlocks. Common synchronization methods like semaphores, mutexes, and monitors are explained.

Uploaded by

Sameer Najam
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Assignment 3: Process Synchronization

1. How can cooperating processes share data?


2. Shared Memory: Processes can communicate by reading and writing to a shared
region of memory. This requires synchronization mechanisms, like semaphores or
mutexes, to avoid conflicts when multiple processes access the shared data
simultaneously.
3. Message Passing: Processes can exchange data by sending messages to each other
through inter-process communication (IPC) mechanisms provided by the operating
system. This can be done through pipes, sockets, message queues, or other IPC
mechanisms.
4. File Sharing: Processes can share data by reading from and writing to common files.
However, this method might be less efficient than shared memory or message
passing, especially for real-time communication or frequent updates.

2. What is a possible problem with concurrent access to shared data?

A significant problem with concurrent access to shared data is the possibility of race
conditions , deadlock , starvation etc

3. In the critical-section problem, Explain the following: (1) race condition (2) entry section
(3) critical section (4) exit section.

4. Explain the two atomic methods of a semaphore.

5. In the Semaphore solution to the Reader-Writer Problem, what is Semaphore mutex used
for?

In the Semaphore solution to the Reader-Writer Problem, the Semaphore mutex (short for
mutual exclusion) is used to control access to the critical section, ensuring that only one
thread (either a reader or a writer) can access the shared resource at a time. This helps in
preventing race conditions and ensuring that data integrity is maintained.

6. what is process synchronization. How process synchronization works.

Process synchronization in OS is the task of coordinating the


execution of processes in such a way that no two processes can
access the same shared data and resources. It is a critical part of
operating system design, as it ensures that processes can safely
share resources without interfering with each other.
7. What is the meaning of the term busy waiting? What other kinds of waiting are there in an
operating system? Can busy waiting be avoided altogether? Explain your answer.

Busy waiting, also known as spinning, refers to a technique in which a process or thread
continuously checks for a condition to become true in a loop without yielding the processor
to other processes or threads.

8. In the Semaphore solution to the Dining-Philosophers Problem, what will happen if each
Philosopher picks up her left chopstick at the same time?
9. If each philosopher picks up her left chopstick at the same time in the
Semaphore solution to the Dining-Philosophers Problem, a deadlock may occur.

10. In the Semaphore solution, each philosopher needs to acquire both the left and
right chopsticks to be able to eat. If all philosophers simultaneously pick up their
left chopsticks and then attempt to pick up their right chopsticks, they will be
unable to proceed because they are waiting for the other philosopher to release
the chopstick they need.

11. A counting semaphore was initialized to 7. Then 20 P (wait) operations and x V


(signal) operations were completed on this semaphore. If the final value of semaphore is 5,
then find the value x.

12.The following program consists of three concurrent processes and three binary semaphores.
The semaphores initialize as S0=1 S1=0 S2=0. How many times will process p0 print “0”

Spinlocks:
• Description: Spinlocks are a form of busy waiting synchronization where a
thread continually checks a lock variable in a loop until it becomes available.
When a thread wants to enter a critical section of code protected by the lock, it
spins in a loop, continuously checking the lock's status. If the lock is held by
another thread, the spinning thread keeps checking until the lock is released.
Test-and-Set Instruction:
• Description: Test-and-set is a hardware-supported atomic instruction used for
synchronization. It atomically sets a memory location to a particular value and
returns its previous value. It is commonly used to implement spinlocks
efficiently.

You might also like