CSE 380 Computer Operating SystemsInterprocess communicationShard MemoryShared Memory in SolarisMessage PassingDesign AttributesInterprocess CommunicationBufferingMailboxesMailbox Issues1CSE 380Computer Operating SystemsInstructor: Insup LeeUniversity of PennsylvaniaFall 2003Lecture Note 2.6: Message-Based Communication2Interprocess communicationShared MemoryMessage PassingSignals3Shard MemoryProcess 1 Process 2 Process 3Shared memory4Shared Memory in SolarisProcesses can share the same segment of memory directly when it is mapped into the address space of each sharing processFaster communicationSystem calls:int shmget(key_t key, size_t size, int shmflg) : creates a new region of shared memory or returns an existing one void *shmat(int shmid, const void *shmaddr, int shmflg) : attaches a shared memory region to the virtual address space of the processint shmdt(char *shmaddr):detaches a shared regionMutual exclusion must be provided by processes using the shared memory5Message Passingmessage6Design AttributesNamingProcess id, mailboxBufferingSize: zero, bounded, unboundedPlace: kernel space, user spaceSend operationSynchronous vs. asynchronousReceive operationBlocking vs. non-blocking7Interprocess CommunicationMessage PassingMany possible naming schemes. One is direct naming: send(process_id, message)receive(process_id, buffer)Exampleprocess P1: process P2: declare x integer declare y integer . . send(P2, x) receive(P1, y) . .end process end processEffect of this communication is y := x | \ local var local var of P2 of P18Buffering•A buffer, with bounded-buffer synchronization, can be associated with each pair of communicating processes.•A “zero-capacity” buffer means processes must “handshake” in order to communicate.A buffer can reside in memory of receiving process or in OS addres space.Examples:no buffer needed P1: send(P2, x) P2: receive(P1, x) receive(P2, y) send(P1, y)buffer needed P1: send(P2, x) P2: send(P1, x) receive(P2, y) receive(P1, y)9MailboxesAlso known as message queues, portsThe explicit and symmetric naming of processes in direct naming Limited modularity since changing the name of a process requires changes elsewhere, i.e., in definitions of other processesmboxPRP or Q callsend(mbox-id, message)R callsreceive(mbox-id, message)Q10Mailbox Issues-communication is no longer “point-to-point”; e.g., a message received by R may be from P or Q-“fair merge” property --- do not starve Q from queuing messages by allowing continual queuing of messages only from P-natural extension to multiple receivers. Possible semantics:-Multicast to all in the group gets the same message-The first receiver removes it-Bulletin board: each receiver
View Full Document