Interprocess Communications Continued Andy Wang COP 5611 Advanced Operating Systems.

Slides:



Advertisements
Similar presentations
Threads, SMP, and Microkernels
Advertisements

Part IV: Memory Management
Memory Protection: Kernel and User Address Spaces  Background  Address binding  How memory protection is achieved.
Chorus and other Microkernels Presented by: Jonathan Tanner and Brian Doyle Articles By: Jon Udell Peter D. Varhol Dick Pountain.
Threads, SMP, and Microkernels Chapter 4. Process Resource ownership - process is allocated a virtual address space to hold the process image Scheduling/execution-
Computer Systems/Operating Systems - Class 8
G Robert Grimm New York University Opal.
Memory Management (II)
3.5 Interprocess Communication Many operating systems provide mechanisms for interprocess communication (IPC) –Processes must communicate with one another.
Inter Process Communication:  It is an essential aspect of process management. By allowing processes to communicate with each other: 1.We can synchronize.
3.5 Interprocess Communication
OS Spring’03 Introduction Operating Systems Spring 2003.
Memory Management 1 CS502 Spring 2006 Memory Management CS-502 Spring 2006.
CS-3013 & CS-502, Summer 2006 Memory Management1 CS-3013 & CS-502 Summer 2006.
Memory ManagementCS-502 Fall Memory Management CS-502 Operating Systems Fall 2006 (Slides include materials from Operating System Concepts, 7 th.
Computer Organization and Architecture
1 Process Description and Control Chapter 3 = Why process? = What is a process? = How to represent processes? = How to control processes?
1 I/O Management in Representative Operating Systems.
PRASHANTHI NARAYAN NETTEM.
1 Threads Chapter 4 Reading: 4.1,4.4, Process Characteristics l Unit of resource ownership - process is allocated: n a virtual address space to.
Layers and Views of a Computer System Operating System Services Program creation Program execution Access to I/O devices Controlled access to files System.
Chapter 51 Threads Chapter 5. 2 Process Characteristics  Concept of Process has two facets.  A Process is: A Unit of resource ownership:  a virtual.
Chapter 8 Windows Outline Programming Windows 2000 System structure Processes and threads in Windows 2000 Memory management The Windows 2000 file.
Operating System A program that controls the execution of application programs An interface between applications and hardware 1.
Operating System Chapter 7. Memory Management Lynn Choi School of Electrical Engineering.
1 Chapter Client-Server Interaction. 2 Functionality  Transport layer and layers below  Basic communication  Reliability  Application layer.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 2: System Structures.
Review of Memory Management, Virtual Memory CS448.
1 Lecture 4: Threads Operating System Fall Contents Overview: Processes & Threads Benefits of Threads Thread State and Operations User Thread.
Chapter 4 Threads, SMP, and Microkernels Patricia Roy Manatee Community College, Venice, FL ©2008, Prentice Hall Operating Systems: Internals and Design.
Cosc 2150: Computer Organization Chapter 6, Part 2 Virtual Memory.
Univ. of TehranDistributed Operating Systems1 Advanced Operating Systems University of Tehran Dept. of EE and Computer Engineering By: Dr. Nasser Yazdani.
Processes and Threads Processes have two characteristics: – Resource ownership - process includes a virtual address space to hold the process image – Scheduling/execution.
Lecture 3 Process Concepts. What is a Process? A process is the dynamic execution context of an executing program. Several processes may run concurrently,
By Teacher Asma Aleisa Year 1433 H.   Goals of memory management  To provide a convenient abstraction for programming  To allocate scarce memory resources.
Chapter 8 – Main Memory (Pgs ). Overview  Everything to do with memory is complicated by the fact that more than 1 program can be in memory.
Threads, SMP, and Microkernels Chapter 4. Process Resource ownership - process is allocated a virtual address space to hold the process image Scheduling/execution-
CE Operating Systems Lecture 3 Overview of OS functions and structure.
8.1 Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9 th Edition Paging Physical address space of a process can be noncontiguous Avoids.
Ihr Logo Operating Systems Internals & Design Principles Fifth Edition William Stallings Chapter 2 (Part II) Operating System Overview.
1 Memory Management Chapter 7. 2 Memory Management Subdividing memory to accommodate multiple processes Memory needs to be allocated to ensure a reasonable.
By Teacher Asma Aleisa Year 1433 H.   Goals of memory management  To provide a convenient abstraction for programming.  To allocate scarce memory.
CS533 - Concepts of Operating Systems 1 The Mach System Presented by Catherine Vilhauer.
Operating Systems Lecture 14 Segments Adapted from Operating Systems Lecture Notes, Copyright 1997 Martin C. Rinard. Zhiqing Liu School of Software Engineering.
Joonwon Lee Process and Address Space.
1 Memory Management Chapter 7. 2 Memory Management Subdividing memory to accommodate multiple processes Memory needs to be allocated to ensure a reasonable.
Lecture 5 Page 1 CS 111 Online Processes CS 111 On-Line MS Program Operating Systems Peter Reiher.
InterProcess Communications 1. Outline IPC fundamentals UNIX sockets Remote procedural call Shared memory and large memory spaces IPC in Windows NT Shared.
The Mach System Silberschatz et al Presented By Anjana Venkat.
Lecture 4 Page 1 CS 111 Online Modularity and Virtualization CS 111 On-Line MS Program Operating Systems Peter Reiher.
Lecture 4 Mechanisms & Kernel for NOSs. Mechanisms for Network Operating Systems  Network operating systems provide three basic mechanisms that support.
CS6502 Operating Systems - Dr. J. Garrido Memory Management – Part 1 Class Will Start Momentarily… Lecture 8b CS6502 Operating Systems Dr. Jose M. Garrido.
COMP091 – Operating Systems 1 Memory Management. Memory Management Terms Physical address –Actual address as seen by memory unit Logical address –Address.
Memory Management Chapter 5 Advanced Operating System.
Copyright © Curt Hill More on Operating Systems Continuation of Introduction.
Memory Protection: Kernel and User Address Spaces Andy Wang Operating Systems COP 4610 / CGS 5765.
Modularity Most useful abstractions an OS wants to offer can’t be directly realized by hardware Modularity is one technique the OS uses to provide better.
Non Contiguous Memory Allocation
Memory Protection: Kernel and User Address Spaces
The Mach System Sri Ramkrishna.
Interprocess Communications Continued
Memory Protection: Kernel and User Address Spaces
Memory Protection: Kernel and User Address Spaces
Memory Protection: Kernel and User Address Spaces
Lecture 14 Virtual Memory and the Alpha Memory Hierarchy
CS399 New Beginnings Jonathan Walpole.
Threads Chapter 4.
CSE 451: Operating Systems Autumn 2003 Lecture 10 Paging & TLBs
CSE 451: Operating Systems Autumn 2003 Lecture 10 Paging & TLBs
Memory Protection: Kernel and User Address Spaces
Presentation transcript:

Interprocess Communications Continued Andy Wang COP 5611 Advanced Operating Systems

Outline  Shared memory IPC  Shared memory and large address spaces  Windows NT IPC Mechanisms

Shared Memory  A simple and powerful form of IPC  Most multiprogramming OS’s use some form of shared memory E.g., sharing executables  Not all OS’s make shared memory available to applications

Shared Memory Diagram Process A Process B x: 10 y: 20 z: __ a: __b: __

Problems with Shared Memory  Synchronization  Protection  Pointers

Synchronization  Shared memory itself does not provide synchronization of communications  Except at the single-word level  Typically, some other synchronization mechanism is used E.g., semaphore in UNIX Events, semaphores, or hardware locks in Windows NT

Protection  Who can access a segment? And in what ways?  UNIX allows some read/write controls  Windows NT has general security monitoring based on the object-status of shared memory

Pointers in Shared Memory  Pointers in a shared memory segment can be troublesome  For that matter, pointers in any IPC can be troublesome

Shared Memory Containing Pointers Process A Process B x: 10 y: 20 z: __ a: __b: __ w: 5

A Troublesome Pointer Process A Process B x: 10 y: 20 z: __ a: __b: __ w: 5

So, how do you share pointers?  Several methods are in use Copy-time translation Reference-time translation Pointer swizzling  All involve somehow translating pointers at some point before they are used

Copy-Time Pointer Translation  When a process sends data containing pointers to another process  Locate each pointer within old version of the data  Then translate pointers are required  Requires both sides to traverse entire structure  Not really feasible for shared memory

Reference-Time Translation  Encode pointers in shared memory segment as pointer surrogates  Typically as offsets into some other segment in separate contexts  So each sharer can have its own copy of what is pointed to  Slow, pointers in two formats

Pointer Swizzling  Like reference-time, but cache results in the memory location  Only first reference is expensive  But each sharer must have his own copy  Must “unswizzle” pointers to transfer data outside of local context  Stale swizzled pointers can cause problems

Shared Memory in a Wide Virtual Address Space  When virtual memory was created, 16 or 32 bit addresses were available  Reasonable size for one process But maybe not for all processes on a machine And certainly not for all processes ever on a machine

Wide Address Space Architectures  Computer architects can now give us 64-bit virtual addresses  A 64-bit address space, consumed at 100 MB/sec, lasts 5000 years Orders of magnitude beyond any process’s needs 40 bits can address a TB

Do we care?  Should OS designers care about wide address space?  Well, what can we do with them?  One possible answer: Put all processes in the same address space Maybe all processes for all time?

Implications of Single Shared Address Space  IPC is trivial Shared memory, RPC  Separation of concepts of address space and protection domain  Uniform address space

Address Space and Protection Domain  A process has a protection domain The data that cannot be touched by other processes And an address space  The addresses it can generate and access  In standard systems, these concepts are merged

Separating the Concepts  These concepts are potentially orthogonal  Just because you can issue an address doesn’t mean you can access it (Though clearly to access an address you must be able to issue it)  Existing hardware can support this separation

Context-Independent Addressing  Addresses mean the same thing in any execution context  So, a given address always refers to the same piece of data  Key concept of uniform-address systems  Allows many OS optimizations/improvements

Uniform-Addressing Allows Easy Sharing  Any process can issue any address So any data can be shared  All that’s required is changing protection to permit desired sharing  Suggests programming methods that make wider use of sharing

To Opal System  New OS using uniform-addressing  Developed at University of Washington  Not intended as slight alteration to existing UNIX system  Most of the rest of material specific to Opal

Protection Mechanisms for Uniform- Addressing  Protection domains are assigned portions of the address space  They can allow other protection domains to access them Read-only Transferable access permissions System-enforced page-level locking

Program Execution in Uniform-Access Memory  Executing a program creates a new protection domain  The new domain is assigned an unused portion of the address space  But it may also get access to used portions  E.g., a segment containing the required executable image

Virtual Segments  Global address space is divided into segments Each composed of variable number of contiguous virtual pages  Domains can only access segments they attach to  Attempting to access unattached segment causes a segment fault

Persistent Memory in Opal  Persistent segments exist even when attached to no current domain  Recoverable segments are permanently stored And can thus survive crashes  All Opal segments can be persistent and recoverable  Pointers can thus live forever on disk

Code Modules in Opal  Executable code stored in modules Independent of protection domains  Pure modules can be easily shared Because they are essentially static  Can get benefit of dynamic loading without run-time linking

Address Space Reclamation  Tricky in uniform-address systems  Problem akin to reclaiming i_nodes in the presence of hard links  But even if segments improperly reclaimed, only trusting domains can be hurt

Windows NT IPC  Inter-thread communications Within a single process  Local procedure calls Between processes on same machine  Shared memory

Windows NT and Threads  Windows NT supports multi-threading  Threads share address space So communication among them is through memory

Windows NT and Client/Server Computing  Windows NT strongly supports the client/server model of computing  Various OS services are built as servers, rather than part of the kernel  Windows NT needs facilities to support client/server operations Which guide users to building client/server solution

Client/Server Computing and RPC  In client/server computing, clients request services from servers  Service can be requested in many ways But RPC is a typical way  Windows NT uses a specialized service for single machine RPC

Local Procedure Call (LPC)  Similar to RPC  Optimized to only work on a single machine  Used to communicate with protected subsystems  Windows NT also provides an RPC facility for distributed computing

Basic Flow of Control in LPC  Application calls routine in an API  Which is usually in a dynamically linked library  Which sends a message to the server through a messaging mechanism

LPC Messaging Mechanisms  Messages between port objects  Message pointers into shared memory  Using dedicated shared memory segments

Port Objects  Windows NT is generally object-oriented  Port objects support communications  Two types: Connection ports Communication ports

Connection Ports  Used to establish connections between clients and servers  Named, so they can be located  Only used to set up communication ports

Communication Ports  Used to actually pass data  Created in pairs, between given client and given server  Private to those two processes  Destroyed when communications end

Windows NT Port Example Client process Server process Connection port

Windows NT Port Example Client process Server process Connection port

Communication ports Windows NT Port Example Client process Server process Connection port

Communication ports Windows NT Port Example Client process Server process Connection port Send request

Message Passing through Port Object Message Queues  One of three methods in Windows NT to pass messages 1. Client submits message to OS 2. OS copies to receiver’s queue 3. Receiver copies from queue to its own address space

Characteristics of Message Passing via Queues  Two message copies required  Fixed-sized, fairly short message ~256 bytes  Port objects stored in system memory So always accessible to OS  Fixed number of entries in message queue

Message Passing Through Shared Memory  Used for messages larger than 256 bytes  Client must create section object Shared memory segment Of arbitrary size  Message goes into the section  Pointer to message sent to receiver’s queue

Setting up Section Objects  Pre-arranged through OS calls  Using virtual memory to map segment into both sender and receiver’s address space  If replies are large, need another segment for the receiver to store responses  OS doesn’t format section objects

Characteristics of Message Passing via Shared Memory  Capable of handling arbitrarily large transfers  Sender and receiver can share a single copy of data i.e., data copied only once  Requires pre-arrangement for section object

Server Handling of Requests  Windows NT servers expect requests from multiple clients  Typically, they have multiple threads to handle requests  Must be sufficiently general to handle many different ports and section objects

Message Passing Through Quick LPC  Third way to pass messages in Windows NT  Used exclusively with Win32 subsystem  Like shared memory, but with a key difference Dedicated resources

Dedicated Resources in Quick LPC  To avoid overhead of copying Notification messages to port queue And thread switching overhead  Client sets up dedicated server thread only for its use  Also dedicated 64KB section object  And event pair object for synchronization

Characteristics of Quick LPC  Transfers of limited size  Very quick  Minimal copying of anything  Wasteful of OS resources

Shared Memory in Windows NT  Similar in most ways to other shared memory services  Windows NT runs on multiprocessors, which complicates things  Done through virtual memory

Shared Memory Sections  Block of memory shared by two or more processes Created with unique name  Can be very, very large

Section Views  Given process might not want to waste lots of its address space on big sections  So a process can have a view into a shared memory section  Different processes can have different views of same section  Or multiple views for single process

Shared Memory View Diagram Process A Process B Physical memory Section view 1view 2 view 3