0% found this document useful (0 votes)
8 views12 pages

Synchronization Problems in Multiprogramming

This document describes six classic process synchronization problems in multiprogrammed operating systems: 1) The dining philosophers, 2) The smoking cigarette problem, 3) Lamport's bakery, 4) The sleeping barber, 5) Readers and writers, 6) Producer/consumer. Each problem presents a scenario where processes compete for shared resources and require mechanisms to coordinate their access and synchronization.

Translated by

ScribdTranslations
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views12 pages

Synchronization Problems in Multiprogramming

This document describes six classic process synchronization problems in multiprogrammed operating systems: 1) The dining philosophers, 2) The smoking cigarette problem, 3) Lamport's bakery, 4) The sleeping barber, 5) Readers and writers, 6) Producer/consumer. Each problem presents a scenario where processes compete for shared resources and require mechanisms to coordinate their access and synchronization.

Translated by

ScribdTranslations
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Problems of

Synchronization of
Processes
In multiprogramming systems with
shared resources are necessary
provide exclusion mechanisms
mutual, which guarantees the synchronization of the
processes when assigning them certain resources and the
coordination in task resolution
commissioned..
In multiprogrammed operating systems the
processes compete for access to resources
shared or cooperate within the same
application to communicate information.

Both situations are handled by the system.


operating through mechanisms of
synchronization that allows exclusive access
in a coordinated manner to the resources and to the
shared communication elements.
A solution is to ensure that a
the critical section of code should only be used by
a process.

There are different algorithms to solve the


critical section problem.

Classically, various have been defined


synchronization problems, what are they
important mainly as examples of
a wide range of control problems
concurrency.
The philosophers who dine (wise)

There are five Chinese philosophers who spend their lives


thinking and eating. They share a table
circular, around which they sit. In their
center is located with an infinite supply of
rice, and on top of it there are five sticks, one of each
side of the philosophers. When a philosopher thinks, he does not
interacts with his colleagues. From time to time, a
philosopher and tries to lift both
sticks closer to him. A philosopher can
pick up one stick at a time, and cannot take one
a stick that is already in the hand of a neighbor.
When a philosopher has both sticks, he can
eat. When I finish doing it, it leaves its two
sticks and start thinking again.
The philosophers who dine (wise)
The one of the cigarette smoker

Consider a system with three smoking processes


and a process agent. Each smoker is
continuously rolling and smoking cigarettes.
However, to roll and smoke a cigarette, the
smoker needs three ingredients: tobacco, paper,
and matches. One of the smoking processes
paper, get the tobacco and the third the matches.
The agent has an infinite amount of the three.
materials. The agent places two of the
ingredients on the table. The smoker has
the remaining ingredient rolls a cigarette and
smoke, notifying the agent when it ends.
Then, the agent places two of the three.
ingredients and the cycle repeats.
3. Lamport's Bakery

In this problem, a bakery has a


variety of breads and pastries sold by n
sellers. Each one of whom takes a
number upon entering. The customer waits until hearing their
number. When the seller is free, call
to the next number.
The Sleepy Barber

A hairdresser has a barber, a chair of


hairdresser and chairs for the clients to sit
waiting, if there are any. If there are no customers
presents, the barber sits in his chair of
hairdresser and falls asleep. When a client arrives,
this must wake up the sleepy barber. If they arrive
more clients while the barber cuts hair
from a client, they must wait seated (if there are
empty chairs) or leave the hair salon (if
all the chairs are occupied). The problem
it consists of scheduling the barber and the clients without
enter into a competitive condition.
5. Readers and Writers

Let's imagine a huge database, like for


example of a reservation system for a line
aerial, with many competing processes, that
they try to read and write in it. It can be accepted
that several processes read the database at the same time
time, but if one of the processes is
writing, (that is, modifying) the basis of
data, none of the other processes should
to have access to this, not even the readers. The
the problem is how to program the readers and
writers.
Readers and writers
6. Producer/Consumer

Also known as 'bounded buffer'


problem of the limited buffer. Two
processes share a warehouse (buffer) of
fixed size. One of them, the producer, places
information in the warehouse (buffer) while
another, the consumer, obtains it from him. If the
producer wants to place a new element, and the
the warehouse is full, this should be taken to
"sleep". The consumer will awaken the producer
when I delete an item from the store. From
in a similar way, if the warehouse is empty and the
consumer wishes to remove an element from the
warehouse, it must "sleep" until the
producer placed something in the warehouse.

You might also like