Commit 91610ad9 authored by Sadman Kazi's avatar Sadman Kazi 🎸

Finish chapter 5

parent 891d74b4
......@@ -120,3 +120,70 @@ Disadvantages:
- In general, anyone can call `semWait()` and `semSignal()`
- For a mutex, only the process with the lock can release the lock
**Monitors**: a software module
- Chief characteristics:
- Local data variables are accessible only by the monitor (shared data in it
are safe)
- Process enters monitor by invoking one of its procedures (controled entry)
- Only one process may be executing in the monitor at a time (mutex)
- Uses condition variables for signaling
- Unused signals are lost (!= semaphores)
![Structure of a monitor](monitor_structure.png)
**Message Passing**
- Enforce mutex
- Exchange info
```
send(destination, message)
receive(source, message)
```
- Synchronization
- Sender and receiver may or may not be blocking (waiting for message)
- Blocking send, blocking receive
- Both sender and receiver are blocked until message is delivered
- Called a rendezvous
- Nonblocking send, blocking receive
- Sender continues on
- Receiver is blocked until the requested message arrives
- Nonblocking send, nonblocking receive
- Neither party is required to wait
- Direct addressing
- **Send** primitive includes a specific identifier of the destination process
- **Receive** primitive could know ahead of time from which process a message
is expected
- **Receive** primitive could use source parameter to return a value when the
receive opertaion has been performed
- Indirect addressing
- Messages are sent to a shared data structure consisting of queues
- Queues are called **mailboxes**
- One process sends a message to the mailbox and the other process picks up the
message from the mailbox
![Indirect process communication](indirect_ipc.png)
- Message format: depends on the requirements of OS (fixed or variable length messages)
+-------------------+-
| Message Type | \
|-------------------| |
| Destination ID | |
|-------------------| \
| Source ID | Header
|-------------------| /
| Message Length | |
|-------------------| |
| Control Info | /
|-------------------|-
| | \
| Message contents | Body
| | /
+-------------------+-
**Fig: General Message Format**
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment