Khoa học máy tính - Chapter 9: Message passing

Message passing paradigm realizes exchange of information among processes without using shared memory Useful in: microkernel-based OSs, client–server computing, higher-level communication protocols, and parallel or distributed programs Sender/receiver naming: symmetric, asymmetric, indirect (mailbox) Message passing is employed in higher-level protocols such as SMTP, RPC, PVM, and MPI

ppt26 trang | Chia sẻ: nguyenlam99 | Lượt xem: 769 | Lượt tải: 0download
Bạn đang xem trước 20 trang tài liệu Khoa học máy tính - Chapter 9: Message passing, để xem tài liệu hoàn chỉnh bạn click vào nút DOWNLOAD ở trên
Chapter 9Message PassingCopyright © 20081Operating Systems, by Dhananjay Dhamdhere*IntroductionOverview of Message PassingImplementing Message PassingMailboxesHigher-Level Protocols Using Message PassingCase Studies in Message Passing2Operating Systems, by Dhananjay Dhamdhere*Overview of Message PassingMessage passing is one way in which processes interact with one anotherProcesses may exist in the same computer or in different computers connected to a networkUses of message passing:Client-server paradigmBackbone of higher-level communication protocolsParallel and distributed programs3Operating Systems, by Dhananjay Dhamdhere*Overview of Message Passing (continued)Two important issues in message passing are:Naming of processesNames may be explicitly indicated or deduced by the kernel in some mannerDelivery of messagesWhether sender should be blocked until deliveryWhat the order is in which messages are delivered to a destination processHow exceptional conditions are handled4Operating Systems, by Dhananjay Dhamdhere*Direct and Indirect NamingIn direct naming, sender and receiver processes mention each other’s nameIn symmetric naming, both sender and receiver processes specify each other’s nameIn asymmetric naming, receiver does not name process from which it wishes to receive a message; kernel gives it a message sent to it by some processIn indirect naming, processes do not mention each other’s name in send and receive statements5Operating Systems, by Dhananjay Dhamdhere*Blocking and Nonblocking SendsA blocking send blocks sender process until message is delivered to destination processSynchronous message passingSimplifies design of concurrent processesA nonblocking send call permits sender to continue its operation after send callAsynchronous message passingEnhances concurrency between sender and receiverIn both cases, receive is typically blockingKernel performs message buffering pending delivery6Operating Systems, by Dhananjay Dhamdhere*Exceptional Conditions in Message PassingTo facilitate handling exceptional conditions, send and receive take two additional parameters:Flags indicate how exceptions should be handledstatus_area is for storing code concerning outcomeSome exceptional conditions:Destination process mentioned in send doesn’t existSource process does not exist (symmetric naming)send cannot be processed (out of buffer memory)No message exists for process when it makes receiveA set of processes become deadlocked when one is blocked on a receive7Operating Systems, by Dhananjay Dhamdhere*Implementing Message Passing8Operating Systems, by Dhananjay Dhamdhere*Delivery of Interprocess MessagesRemember that:An event control block (ECB) has three fields:Description of the anticipated eventId of the process that awaits the eventAn ECB pointer for forming ECB lists9Operating Systems, by Dhananjay Dhamdhere*10Operating Systems, by Dhananjay Dhamdhere*MailboxesMailbox: repository for interprocess messagesHas a unique nameOwner is typically the process that created itIndirect namingOnly owner process can receive messagesAny process that knows name of a mailbox can send messages to itKernel may provide fixed set of mailbox names, or it may permit user processes to assign the namesVarying levels of confidentiality11Operating Systems, by Dhananjay Dhamdhere*Mailboxes (continued)12Operating Systems, by Dhananjay Dhamdhere*Mailboxes (continued)Kernel may require a process to explicitly “connect” to a mailbox before starting to use it, and to “disconnect” when it finishes using itMay permit owner to destroy it, transfer ownership, etc.Use of a mailbox has following advantages:Anonymity of receiverClassification of messages Through use of separate mailboxes for different classes13Operating Systems, by Dhananjay Dhamdhere*Example: Use of MailboxesAn airline reservation system:A set of booking processesServer wishes to process cancellations before bookings and queries after both of them14Operating Systems, by Dhananjay Dhamdhere*Higher-Level Protocols Using Message PassingSeveral protocols use message passing paradigm to provide diverse services:Simple mail transfer protocol (SMTP) delivers electronic mailRemote procedure call (RPC) is a programming language facility for distributed computingInvokes a part of a program that is located on a different computerParallel virtual machine (PVM) and message passing interface (MPI) are message passing standards for parallel programming15Operating Systems, by Dhananjay Dhamdhere*The Simple Mail Transfer Protocol (SMTP)SMTP is used to deliver electronic mail to one or more users reliably and efficientlyUses asymmetric namingCan deliver mail across a number of interprocess communication environments (IPCEs )It is an applications layer protocol: uses TCP / IPSMTP consists of several simple commands:MAIL, RCPT, DATATypically used with a protocol that provides a mailboxInternet Message Access Protocol (IMAP)Post Office Protocol (POP)16Operating Systems, by Dhananjay Dhamdhere*Remote Procedure CallsRemote procedure call (RPC): used to invoke a part of a program located in a different computerSemantics resemble those of a procedure callcall (); is a list of parametersStubs perform marshaling of parameters and convert them to/from machine independent representationsSunRPC and OSF/DCE standards, Java RMI17Operating Systems, by Dhananjay Dhamdhere*Message Passing Standards for Parallel ProgrammingParallel program: set of tasks that can be performed in parallelExecuted on a heterogeneous set of computers or on a massively parallel processor (MPP)Parallel virtual machine (PVM) and message passing interface (MPI) are standards used in coding message passing libraries; provide:Point-to-point communication between processesBarrier synchronization between processesGlobal operations for scattering (gathering) disjoint portions of data in a message to (from) different processes18Operating Systems, by Dhananjay Dhamdhere*Case Studies in Message PassingMessage Passing in UnixMessage Passing in Windows19Operating Systems, by Dhananjay Dhamdhere*Message Passing in UnixThree interprocess communication facilities:Pipe:Data transfer facilityUnnamed pipes can be used only by processes that belong to the same process treeMessage queue: analogous to a mailboxUsed by processes within “Unix system domain”Access permissions indicate which processes can send or receive messagesSocket: one end of a communication pathCan be used for setting up communication paths between processes within the Unix system domain and within certain Internet domains20Operating Systems, by Dhananjay Dhamdhere*Message Passing in Unix (continued)One common feature: processes can communicate without knowing each other’s identities21Operating Systems, by Dhananjay Dhamdhere*Message Passing in Unix: PipesFIFO mechanism for data transfer between processes called reader and writer processesUsually implemented in file systemBut, data put into a pipe can be read only onceRemoved from pipe when it is read by a processTwo kinds of pipes: named and unnamedCreated through the system call pipeA named pipe has an entry in a directoryLike a file, but size is limited and kernel treats it as a queue22Operating Systems, by Dhananjay Dhamdhere*Message Passing in Unix: Message QueuesAnalogous to a mailboxCreated and owned by one processCreator specifies access permissions for send/receiveSize specified at the time of its creation23Operating Systems, by Dhananjay Dhamdhere*Message Passing in Unix: SocketsA socket is one end of a communication pathCan be used for interprocess communication within the Unix system domain and in the Internet domainServer can set up communication paths with many clients simultaneouslyTypically, after connect call, server forks a new process to handle the new connectionLeaves original socket created by server process free to accept more connectionsIndirect naming: address (domain) used instead of process ids24Operating Systems, by Dhananjay Dhamdhere*Message Passing in WindowsNamed pipes: reliable bidirectional byte/message mode communication between server and clientsImplemented through the file system interfaceSynchronous and asynchronous message passingLocal Procedure Call (LPC) facility performs message passing between processes in same hostChoice of three methods of message passingWindows socket (Winsock)Integrated with Windows message passingRPC: Synchronous and asynchronous25Operating Systems, by Dhananjay Dhamdhere*SummaryMessage passing paradigm realizes exchange of information among processes without using shared memoryUseful in: microkernel-based OSs, client–server computing, higher-level communication protocols, and parallel or distributed programsSender/receiver naming: symmetric, asymmetric, indirect (mailbox)Message passing is employed in higher-level protocols such as SMTP, RPC, PVM, and MPI26

Các file đính kèm theo tài liệu này:

  • pptchapter_09_2843.ppt
Tài liệu liên quan