OS 3 InterProcessesCommunication
OS 3 InterProcessesCommunication
ECEG-5202
Inter-Processes Communication
Next_free_slot
• Disabling interrupt
– Disable all interrupts just after entering its critical
region and re-enable them just before leaving it
– No clock interrupts can occur
– Simple
– Not a good choice. Why?
• Gives user processes the power to turn off interrupts
• Doesn’t work in a system with multiprocessor
– Disabling interrupts affects only the CPU that executes the disable
instruction, other processes on other CPUs could access it
• Problem
1. Producer wants to put a new item in the buffer, but it is already full
» Soln.: Producer goes to sleep
2. Consumer wants to remove an item from the buffer and sees that the
buffer is empty
» Soln.: Consumer goes to sleep
• Question
– How can they share the turn variable in Peterson’s algorithm, or
semaphores or a common buffer?
• Answer
1. Semaphores can be stored in the kernel and accessed only by means
of system calls
2. Most modern OSs offer a way for processes to share some portion
of their address space with other processes
3. Using shared files
– Solution
• Higher level synchronization
primitive: Monitor