stacey levine chapter 4.1 message passing communication

22
Stacey Levine Stacey Levine Chapter 4.1 Message Passing Communication

Upload: oscar-brooks

Post on 19-Jan-2016

224 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Stacey Levine Chapter 4.1 Message Passing Communication

Stacey LevineStacey LevineChapter 4.1Message Passing Communication

Page 2: Stacey Levine Chapter 4.1 Message Passing Communication

Introduction Introduction

Basic Message passing

Page 3: Stacey Levine Chapter 4.1 Message Passing Communication

Communication ModelsCommunication Models

Support for processes to communicate among themselves.

Traditional (centralized) OS’s:– Provide local (within single machine)

communication support.– Distributed OS’s: must provide support for

communication across machine boundaries.Over LAN or WAN.

Page 4: Stacey Levine Chapter 4.1 Message Passing Communication

Message PassingMessage Passing

Basic communication primitives:– Send message.

– Receive message.

Modes of communication:– Synchronous versus asynchronous.

...Send

Sending Q

...

Receiving Q

Page 5: Stacey Levine Chapter 4.1 Message Passing Communication

Synchronization StagesSynchronization Stages

Sender source network destination receiver

kernelMessage

ack

Non blocking send is 1st step. Everything else is blocking

Page 6: Stacey Levine Chapter 4.1 Message Passing Communication

Communication may take place using either message passing or shared memory.

Communication ModelsCommunication Models

Page 7: Stacey Levine Chapter 4.1 Message Passing Communication

Synchronous CommunicationSynchronous Communication

Blocking send– Blocks until message is transmitted – Blocks until message acknowledged

Blocking receive– Waits for message to be received

Process synchronization.

Page 8: Stacey Levine Chapter 4.1 Message Passing Communication

Asynchronous CommunicationAsynchronous Communication

Non-blocking send: sending process continues as soon as message is queued.

Blocking or non-blocking receive:– Blocking:

Timeout. Threads.

– Non-blocking: proceeds while waiting for message. Message is queued upon arrival. Process needs to poll or be interrupted.

Page 9: Stacey Levine Chapter 4.1 Message Passing Communication

Direct CommunicationDirect Communication

Page 10: Stacey Levine Chapter 4.1 Message Passing Communication

Indirect CommunicationIndirect Communication Indirect communications :

– messages sent to and received from mailboxes (or ports) mailboxes can be viewed as objects into which messages placed by

processes and from which messages can be removed by other processes

– each mailbox has a unique ID

– two processes can communicate only if they have a shared mailbox

Page 11: Stacey Levine Chapter 4.1 Message Passing Communication

The Producer Consumer The Producer Consumer ProblemProblem The producer-consumer problem illustrates the

need for synchronization in systems where many processes share a resource. In the problem, two processes share a fixed-size buffer. One process produces information and puts it in the buffer, while the other process consumes information from the buffer. These processes do not take turns accessing the buffer, they both work concurrently. Herein lies the problem. What happens if the producer tries to put an item into a full buffer? What happens if the consumer tries to take an item from an empty buffer?

Page 12: Stacey Levine Chapter 4.1 Message Passing Communication

ProducerProducer

Page 13: Stacey Levine Chapter 4.1 Message Passing Communication

ConsumerConsumer

Page 14: Stacey Levine Chapter 4.1 Message Passing Communication

Sleep and WakeupSleep and Wakeup

Waiting is wasteful Processes waiting to enter their critical sections

waste processor time checking to see if they can proceed – when a process is not permitted to access its critical

section, it uses a system call known as Sleep, which causes that process to block

– . The process will not be scheduled to run again, until another process uses the Wakeup system call

Page 15: Stacey Levine Chapter 4.1 Message Passing Communication

SemaphoresSemaphores

In the Producer-Consumer problem, semaphores are used for two purposes:

mutual exclusion and synchronization.

Page 16: Stacey Levine Chapter 4.1 Message Passing Communication

Sleep and Wakeup using MonitorsSleep and Wakeup using Monitors

Page 17: Stacey Levine Chapter 4.1 Message Passing Communication

Message PassingMessage Passing

Sempahores and Monitors use shared memory.

Not effective on Distributed systems

Page 18: Stacey Levine Chapter 4.1 Message Passing Communication

Sleep and Wakeup using Message PassingSleep and Wakeup using Message Passing

Two primitives, SEND and RECEIVE are used in the message passing scheme. • SEND primitive sends a message to a destination process • RECEIVE primitive receives a message from a specified source process.

•Message Passing works on distributed systems because these messages can be sent from machine to machine through a network. Typically, each process has a mailbox; a buffer which receives all the messages which are sent to that process. The destination of the SEND and RECEIVE system calls is a process' mailbox, not the process itself.

Page 19: Stacey Levine Chapter 4.1 Message Passing Communication

Message Passing InterfaceMessage Passing Interface

http://www.mpi-forum.org/MPI is a message-passing standardProcess = A regular sequential

language + calls to MPI functions for sending and receiving messages

MPI has many implementations, MPI contains > 130 functions

MPI 2.1 is the current version

Page 20: Stacey Levine Chapter 4.1 Message Passing Communication

How is Mutual Exclusion implemented with Message PassingHow is Mutual Exclusion implemented with Message Passing

This pictures shows an interaction between a process that wants to access a shared resource, and a resource control process. Three messages are sent here. Message (1) is a request for access to the resource. Process P1 then blocks, waiting for a reply from the resource control process. Message (2) is the reply sent by the control process. This message wakes up P1, and P1 now uses the resource. Message (3) informs the resource control process that P1 is done using the resource.

Page 21: Stacey Levine Chapter 4.1 Message Passing Communication

Examples ….Examples ….

SSLLocal system events (mouse movements..)HTTPRPC …

Page 22: Stacey Levine Chapter 4.1 Message Passing Communication

ReferencesReferences Operating System Concepts, Silberschatz,Galvin and Gange 2002 Message passing information from The University of Edinburgh MPI-2: standards beyond the message-passing model

Lusk, E.;Massively Parallel Programming Models, 1997. Proceedings. Third Working Conference on12-14 Nov. 1997 Page(s):43 - 49 Digital Object Identifier 10.1109/MPPM.1997.715960

A multithreaded message-passing system for high performance distributed computing applicationsPark, S.-Y.; Lee, J.; Hariri, S.;Distributed Computing Systems, 1998. Proceedings. 18th International Conference on26-29 May 1998 Page(s):258 - 265 Digital Object Identifier 10.1109/ICDCS.1998.679521

Lessons for massively parallel applications on message passing computersFox, G.C.;Compcon Spring '92. Thirty-Seventh IEEE Computer Society International Conference, Digest of Papers.24-28 Feb. 1992 Page(s):103 - 114 Digital Object Identifier 10.1109/CMPCON.1992.186695

An analysis of message passing systems for distributed memory computersClematis, A.; Tavani, O.;Parallel and Distributed Processing, 1993. Proceedings. Euromicro Workshop on27-29 Jan. 1993 Page(s):299 - 306 Digital Object Identifier 10.1109/EMPDP.1993.336388

Chandras, R. G. 1990. Distributed message passing operating systems. SIGOPS Oper. Syst. Rev. 24, 1 (Jan. 1990), 7-17. DOI= http://doi.acm.org/10.1145/90994.90999