Operating System/O.S(Neso Academy, HPC Lab. KOREATECH)

7)Shared Memory Systems , Message Passing Systems

Tony Lim 2021. 5. 5. 21:01
728x90

IPC using shared memory requires communicating process to establish a region of shared memory.

shared memory region reside in the address space of the process creating shared memory segment

other process that wish to communciate using this shared-memory segment must attach it to their address space.

normally the OS tries to prevent one process from accessing antoher process's memory but shared memory requries that 2 or more processes agree to remove this restriction.

 

Producer Consumer Problem

how to work concurrently. 

to allow producer and consumer processes to run concurrently , we must have available a buffer of items that can be filled by the producer and emptied by the consumer.

producer and consumber must be synchronized.

buffer

  • unbounded buffer = no limit of size of the buffer. the consumer may have to wait for new items but the producer can continuously produce new items.
  • bounded buffer = fixed buffer size. consumer wait if buffer is empty also producer wait if buffer is full.

 

Message Passing Systems

allow process to communciate and to synchronize their actions without sharing the same address space and is particularly useful in a distributed environment, where the communcicating prcoess may reside on different computers connected by a network.

 

Messages sent by a process can be of either fixed or variable size

fixed = The system level implementation is simple but makes the task of programming more difficult.

variable = System level hard but task of programming simpler.

 

communciation link (logical)

Direct or indrect communciation

Naming = prcoess that wan to communicate must have a way to refer to each other. 

direct communication 
send (P, message) == Send a message to process P 
receive (Q , message) == receive a message from process Q.

symmetry in addressing = both sender and receiver must name the other to communicate.


variant of direct communication 
send (P, message) == send a message to process P 
receive (id , message) == Receive a message from any process , id is just variable 

asymmetry in addressing = only sender is directly name process.

if the name of process changes this communication won't work.


indirection communication

the messages are sent to and received from mailboxes or ports , 2 or more process can communicate only if the processes have a shared mailbox

mailboxes can be either owned by process or OS.  if owned by process and this process exit then mailbox will also. but OS won't.


Synchronous or asynchronous communication

blocking send (Synchronous) = sending process is blocked until the message is received by the receiving process or by the receiving process or by the mailbox.

nonblocking send (asynchronous) = sending process sends the message and resumes operation. 

blocking receive = the receiver blocks until a message is available.

nonblocking receive = the receiver retrieves either a vaild message or a null.


automatic or explicit buffering

where messages reside either direct or indirect.

zero capcaity = the sender must block until the recipient receives the message. acts like a link.

bounded capacity = sender can continuosly produce without waiting.

unbounded capacity = any nubmer of messages can wait in it. sender never get blocked.

 

 

 

 

728x90