Sei sulla pagina 1di 3

Multiprocessing

Important topics to discuss when looking at concurrency are multiprocessing


and scheduling, as depicted in the following diagram:

(Stallings, 2009)

Concurrency Challenges

The operating system must accomplish the following objectives that may also
present issues:

Keep track of processes


Allocate and de-allocate resources
Protect resources against interference from other processes
Ensure processes and output are independent of processing speed
Sharing of global resources
Optimal resource allocation
Operating systems implemented as a set of concurrent
processes/threads

Trying to accomplish concurrency by interleaving processes can produce


different outputs depending on the order in which they were interleaved. This
can cause errors, which could result in a dirty read or lost update problems.

The following can be implemented to avoid the errors that can occur when
utilizing concurrency:

1
Multiprocessing

Serialization: Only one process runs at a time.


Atomicity: A process cannot be interrupted.
Mutual exclusion: This combines serialization and atomicity, which are
required in critical sections.

However, mutual exclusion can also create control problems:

Deadlock: Two processes in constant wait state


Starvation: Some processes are never granted access, while others
receive priority

Therefore, one of the important features of a modern operating system is its


ability to concurrently execute processes and threads. This is essential to
multiprogramming, multiprocessing, distributed systems, and the client–server
model. Modern operating systems must effectively support communication and
synchronization within processes and must support sharing of and contention
for resources.

Synchronization and Communication

A basic premise for processes interacting with one another is that


synchronization and communication are requirements that must be satisfied. A
solution to communication is message passing. Because this mechanism works
with shared memory, it is also a good approach for distributed systems. The
function of message passing occurs in the form of a pair of primitives: send
(destination, message) and receive (source, message).

Synchronization:

coordinates independent threads.


reduces nondeterminism in the order of processing.

Communication:

is a message between two processes.


requires synchronization between the receiver and sender.
prohibits a receiver receiving a message until it has been sent by
another process.

The following are the three types of message passing:

2
Multiprocessing

Synchronization
o Sender and receiver may or may not be blocking
o Sender blocked until message is received
o Receiver blocked until message is received
o Both sender and receiver are blocked
o Nonblocking send, blocking receive
o Nonblocking send, nonblocking receive
Direct addressing
o Send includes specific identification of destination process
o Receive could require receiver to explicitly designate a sender
o Receive could use source parameter to return to calling process
when receive is performed
Indirect addressing
o Messages sent to shared data structure consisting of queues
o Queues sometimes known as mailboxes
o One process sends a message to mailbox and other process picks
up message from mailbox

Other Concurrency Mechanisms

Semaphore: Special variables or integer counter used for signaling


Monitor: Encapsulates shared data with the access functions

Reference

Stallings, W. (2009). Operating systems: Internals and design principles (6th


ed.). Pearson Education International. Retrieved from
http://www.informatik.unikiel.de/fileadmin/arbeitsgruppen/comsys/files/
ws0809/05_concurrency.pdf

Potrebbero piacerti anche