Operating System Support

Similar documents
Figure 6.1 System layers

Operating System Support

Applications, services. Middleware. OS2 Processes, threads, Processes, threads, communication,... communication,... Platform

0. Course Overview. 8 Architecture models; network architectures: OSI, Internet and LANs; interprocess communication III. Time and Global States

Process Management. Processes. Processes. Processes, Threads, and Agents. A distributed system is a collection of cooperating processes.

Lecture 5: Object Interaction: RMI and RPC

Verteilte Systeme (Distributed Systems)

03 Remote invoaction. Request-reply RPC. Coulouris 5 Birrel_Nelson_84.pdf RMI

Distributed Systems Lecture 2 1. External Data Representation and Marshalling (Sec. 4.3) Request reply protocol (failure modes) (Sec. 4.

Distributed Systems. Definitions. Why Build Distributed Systems? Operating Systems - Overview. Operating Systems - Overview

Chapter 5: Distributed objects and remote invocation

Remote Invocation. Today. Next time. l Overlay networks and P2P. l Request-reply, RPC, RMI

CSci Introduction to Distributed Systems. Communication: RPC

Structured communication (Remote invocation)

Lecture 06: Distributed Object

Lightweight Remote Procedure Call

RMI: Design & Implementation

CS555: Distributed Systems [Fall 2017] Dept. Of Computer Science, Colorado State University

Lightweight Remote Procedure Call. Brian N. Bershad, Thomas E. Anderson, Edward D. Lazowska, and Henry M. Levy Presented by Alana Sweat

Lecture 2 Process Management

COMP 6231: Distributed System Design

Chapter 5: Remote Invocation. Copyright 2015 Prof. Amr El-Kadi

Lecture 17: Threads and Scheduling. Thursday, 05 Nov 2009

Communication. Distributed Systems Santa Clara University 2016

Distributed Objects and Remote Invocation. Programming Models for Distributed Applications

Unit 7: RPC and Indirect Communication

Lightweight RPC. Robert Grimm New York University

Processes and Threads

Distributed Information Processing

Threads, SMP, and Microkernels. Chapter 4

CHAPTER - 4 REMOTE COMMUNICATION

Remote Invocation. Today. Next time. l Indirect communication. l Request-reply, RPC, RMI

Last Class: RPCs. Today:

CS533 Concepts of Operating Systems. Jonathan Walpole

Chapter 4 Communication

Distributed Systems. Lehrstuhl für Informatik 4. RWTH Aachen. Organization. Literature. Classification of the lecture

Slides for Chapter 5: Remote Invocation

Slides on cross- domain call and Remote Procedure Call (RPC)

Chapter 5 Remote Invocation. Gandeva Bayu Satrya, ST., MT. Telematics Labz. Informatics Department Telkom

Interprocess Communication

Process. Program Vs. process. During execution, the process may be in one of the following states

Lecture 5: Process Description and Control Multithreading Basics in Interprocess communication Introduction to multiprocessors

Remote Procedure Call

CHAPTER 3 - PROCESS CONCEPT

Process Description and Control

Microkernels and Client- Server Architectures

Chapter 3: Processes. Operating System Concepts 8th Edition

Chapter 5: Processes & Process Concept. Objectives. Process Concept Process Scheduling Operations on Processes. Communication in Client-Server Systems

Part V. Process Management. Sadeghi, Cubaleska RUB Course Operating System Security Memory Management and Protection

Operating System. Chapter 4. Threads. Lynn Choi School of Electrical Engineering

SAI/ST course Distributed Systems

DS 2009: middleware. David Evans

MODELS OF DISTRIBUTED SYSTEMS

Remote Invocation. To do. Request-reply, RPC, RMI. q Today q. q Next time: Indirect communication

Chapter 3: Processes. Operating System Concepts 9 th Edition

Last Class: RPCs. Today:

CS555: Distributed Systems [Fall 2017] Dept. Of Computer Science, Colorado State University

Operating System Architecture. CS3026 Operating Systems Lecture 03

Process Scheduling Queues

Today: Distributed Objects. Distributed Objects

MODELS OF DISTRIBUTED SYSTEMS

CSE473/Spring st Midterm Exam Tuesday, February 19, 2007 Professor Trent Jaeger

Overview. Thread Packages. Threads The Thread Model (1) The Thread Model (2) The Thread Model (3) Thread Usage (1)

OPERATING SYSTEM. Chapter 4: Threads

Outline. EEC-681/781 Distributed Computing Systems. The OSI Network Architecture. Inter-Process Communications (IPC) Lecture 4

Motivation. Threads. Multithreaded Server Architecture. Thread of execution. Chapter 4

Chapter 4: Threads. Overview Multithreading Models Thread Libraries Threading Issues Operating System Examples Windows XP Threads Linux Threads

Communication. Overview

A Comparison of Two Distributed Systems: Amoeba & Sprite. By: Fred Douglis, John K. Ousterhout, M. Frans Kaashock, Andrew Tanenbaum Dec.

Threads. Raju Pandey Department of Computer Sciences University of California, Davis Spring 2011

Distributed Systems. Lehrstuhl für Informatik IV RWTH Aachen. Organisation. Classification of the lecture. Literature

Chapter 4: Multi-Threaded Programming

Module 3 - Distributed Objects & Remote Invocation

! How is a thread different from a process? ! Why are threads useful? ! How can POSIX threads be useful?

Outline. Interprocess Communication. Interprocess Communication. Communication Models: Message Passing and shared Memory.

!! How is a thread different from a process? !! Why are threads useful? !! How can POSIX threads be useful?

MTAT Enterprise System Integration. Lecture 2: Middleware & Web Services

1 System & Activities

Advanced Topics in Distributed Systems. Dr. Ayman A. Abdel-Hamid. Computer Science Department Virginia Tech

A Report on RMI and RPC Submitted by Sudharshan Reddy B

How do modules communicate? Enforcing modularity. Modularity: client-server organization. Tradeoffs of enforcing modularity

Lecture 15: Network File Systems

Chapter 4: Threads. Chapter 4: Threads

Concurrent Programming using Threads

Questions answered in this lecture: CS 537 Lecture 19 Threads and Cooperation. What s in a process? Organizing a Process

Chapter 3: Client-Server Paradigm and Middleware

Threads Implementation. Jo, Heeseung

Distributed Systems Principles and Paradigms

DISTRIBUTED OBJECTS AND REMOTE INVOCATION

Chapter 4: Processes. Process Concept

殷亚凤. Processes. Distributed Systems [3]

Chapter 4: Threads. Chapter 4: Threads. Overview Multicore Programming Multithreading Models Thread Libraries Implicit Threading Threading Issues

Overview. Communication types and role of Middleware Remote Procedure Call (RPC) Message Oriented Communication Multicasting 2/36

02 - Distributed Systems

Chapter 4: Processes

02 - Distributed Systems

Chapter 4: Threads. Operating System Concepts 9 th Edit9on

Exam Guide COMPSCI 386

I.-C. Lin, Assistant Professor. Textbook: Operating System Concepts 8ed CHAPTER 4: MULTITHREADED PROGRAMMING

Communication Paradigms

Transcription:

Operating System Support Dr. Xiaobo Zhou Adopted from Coulouris, Dollimore and Kindberg Distributed Systems: Concepts and Design Edition 4, Addison-Wesley 2005 1 Learning Objectives Know what a modern operating system does to support distributed applications and middleware Definition of network OS Definition of distributed OS Understand the relevant abstractions and techniques, focussing on: processes, threads, and support for invocation mechanisms. Understand the options for operating system architecture monolithic and micro-kernels If time: Lightweight RPC 2 1

System Layers What is the impact of particular OS mechanisms on middleware s ability to deliver distributed resource sharing to the users? Applications, services Middleware OS: kernel, libraries & servers Figure 2.1 Software and hardware service layers in distributed systems OS1 OS2 Processes, threads, Processes, Applications, servicesthreads, communication,... communication,... Middleware Platform Computer & Computer & network hardware network Operating system hardware Node 1 Node 2 Computer and network hardware Platform 3 Middleware and the Operating System Middleware implements abstractions that support networkwide programming. Examples: RPC and RMI (Sun RPC, Corba, Java RMI) event distribution and filtering (Corba Event Notification) resource discovery for mobile and ubiquitous computing support for multimedia streaming Traditional OS's (e.g. early Unix, Windows 3.0) simplify, protect and optimize the use of local resources Network OS's (e.g. Mach, modern UNIX, Windows NT) do the same but they also support a wide range of communication standards and enable remote processes to access (some) local resources (e.g. files); telnet, rlogin. 4 2

Distributed OS vs. Network OS What is a distributed OS? Presents users (and applications) with an integrated computing platform (a single system image) that hides the individual computers. Has control over all of the nodes (computers) in the network and allocates their resources to tasks without user involvement. In a distributed OS, the user doesn't know (or care) where his programs are running scheduling is transparent Examples: Cluster computer systems V system, Sprite, Globe OS Network OS's vs. Distributed OS The nodes retain autonomy in managing their own processing resources (multiple system images, one per node) It does not schedule processes across the nodes, requiring user involvement; e.g., UNIX, Win NT 5 The Support Required by OS OS manages the basic resources of computer systems: processing, memory, persistent storage and communication. It is the task of an operating system to: raise the programming interface for the resources to a more useful level: Encapsulation: by providing abstractions of the basic resources such as: processes, unlimited virtual memory, files, communication channels Protection of the resources used by applications Concurrent processing to enable applications to complete their work with minimum interference from other applications provide the resources needed for (distributed) services and applications to complete their task: Communication within a computer or network access provided Scheduling - processors scheduled at the relevant computer(s) 6 3

Core OS functionality Process manager Communication manager Thread manager Memory manager Supervisor Supervisor (hardware abstraction): Dispatching of interrupts, system call traps, and other exceptions. Control of memory management unit and hardware caches. 7 Kernels and Protection Kernel: A program that always runs and its code is executed with complete access privileges for the physical resources on its host computer Sets up address space for protection Protection A process cannot access memory outside its address space A process executes kernel code in the kernel s address space User-level address space to kernel by Interrupt or a system-call trap Cost: kernel-user switching takes many clock cycles; a system-call trap is more expensive than a simple procedure call or method call (user space user space) 8 4

Processes and Threads Concurrency: Multi-threading, a thread is an OS abstraction of a schedulable activity. Overlapping computation with input and output, and enabling concurrent processing on multi-processors Process An execution environment with one or more threads Process abstraction serves as a protection domain Execution environments is also a resource allocation unit An address space Thread synchronization and communication resources, semaphores, communication interface like sockets Higher-level resource such as open files and windows 9 Process Address Space 2 N What is a region? 0 Auxiliary regions Stack Heap Text An area of contiguous virtual memory accessible by the threads of the owning process Region: (extent, permission, grown or not) A separate stack for each thread Regions can be shared kernel code (mapped at the same location) Libraries; mapped as a region in address spaces shared data & communication UNIX fork() is expensive must copy process's address space copy-on-write 10 5

Creation of a New Process Choice of Process Host Transfer policy: Situate a new process locally or remotely Location policy: Which node should host a new process selected for transfer Sprite: commands for executing an idle workstation in a NOW system Load sharing: Static vs. dynamic process location Centralized, hierarchical, or decentralized load managing Sender-initiated vs. receiver-initiated process transferring Process migration: benefit vs. cost Round-Robin (RR), WRR, shortest-queue-first, least-remaining-first, etc. The simplicity principle 11 Creation of a New Execution Environment: Copy-on-write Process A s address space Process B s address space RA RB copied from RA (not physically) RB Kernel A's page table Shared frame B's page table a) Before write b) After write 12 6

Threads Concept and Implementation Process Thread activations Activation stacks (parameters, local variables) Heap (dynamic storage, objects, global variables) 'text' (program code) system-provided resources (sockets, windows, open files) 13 Client and Server with Threads: Work Pool Thread 2 makes requests to server (blocking RMI typically) y) Receipt & queuing Input-output Thread 1 generates results buffer Requests N threads Client Server The 'worker pool' architecture (fixed usually); shared queue See Figure 4.6 for an example of this architecture programmed in Java (using TCP sockets). 14 7

Alternative Server Threading Architectures server process workers server process per-connection threads server process per-object threads/queues I/O remote objects remote objects I/O remote objects a. Thread-per-request b. Thread-per-connection c. Thread-per-object Implemented by the server-sideside ORB in CORBA (a) would be useful for UDP-based service, e.g. NTP; (b) is the most commonly used - matches the TCP connection model (c) is used where the service is encapsulated as an object. Each object has only one thread at a time, avoiding the need for thread synchronization within objects. How about queueing? Cost? Load sharing? 15 Threads versus Multiple Processes Creating a thread is (much) cheaper than a process (~10-20 times) Switching to a different thread in same process is (much) cheaper (5-50 times) Scheduling and context switching (state saving + possible domain transition) Threads within same process can share data and other resources more conveniently and efficiently (without copying or message passing) But, threads within a process are not protected from each other What key factors decide cost of thread operations? Figure 6.7 State associated with execution environments and threads Execution environment Thread Address space tables Saved processor registers Communication interfaces, open filespriority and execution state (such as BLOCKED, RUNABLE, SUSPENDED) Semaphores, other synchronization Software interrupt handling information objects (e.g., UNIX Signals) List of thread identifiers Execution environment identifier 16 8

Java Thread Constructor and Management Methods Methods of objects that inherit from class Thread Thread(ThreadGroup group, Runnable target, String name) Creates a new thread in the SUSPENDED state, which will belong to group and be identified as name; the thread will execute the run() method of target. setpriority(int newpriority), getpriority() Set and return the thread s priority. run() A thread executes the run() method of its target object, if it has one, and otherwise its own run() method (Thread implements Runnable). start() Change the state of the thread from SUSPENDED to RUNNABLE. sleep(int millisecs) Cause the thread to enter the SUSPENDED state for the specified time. yield() Enter the READY state and invoke the scheduler. //for non-preemptive scheduling destroy(): Destroy the thread. 17 Java Thread Synchronization Calls thread.join(int millisecs) Blocks the calling thread for up to the specified time until thread has terminated. thread.interrupt() Interrupts thread: causes it to return from a blocking method call such as sleep(). object.wait(long millisecs, int nanosecs) Blocks the calling thread until a call made to notify() or notifyall() on object wakes the thread, or the thread is interrupted, or the specified time has elapsed. object.notify(), object.notifyall() object.wait() Wakes, and respectively, object.notify() one or are all very of any threads that have called wait() on Receipt & I/O similar object. queuing to the semaphore operations. E.g. a worker thread would use queue.wait() to wait for Requests incoming requests. N threads Server 18 9

Threads Implementation Threads can be implemented: in the OS kernel (Win NT, Solaris, Mach) at user level (e.g. by a thread library: C threads, pthreads), or in the language (Ada, Java). + lightweight - no system calls + modifiable scheduler + low cost enables more threads to be employed - not pre-emptive - cannot exploit multiple processors - - page fault blocks all threads Java can be implemented either way hybrid approaches can gain some advantages of both user-level hints to kernel scheduler hierarchical threads (Solaris) event-based (SPIN, FastThreads) 19 Support for Communication and Invocation The performance of RPC and RMI mechanisms is critical for effective distributed systems. Typical times for 'null procedure call (w/o parameters): Local procedure call < 1 microseconds 10,000 times slower! Remote procedure call ~ 10 milliseconds 'network time' (involving about 100 bytes transferred, at 100 megabits/sec.) accounts for only.01 millisecond; the remaining delays must be in OS and middleware - latency, not communication time. What key factors determines invocation cost? 20 10

Factors Affecting RPC/RMI Performance object A client proxy for B Request server skeleton & dispatcher for B s class remote object B Reply Remote Communication reference module module Communication module Remote reference module marshalling/unmarshalling + operation despatch at the server data copying: application -> kernel space -> communication buffers protocol processing: for each protocol layer network access delays: connection setup, network latency thread scheduling and context switching: including kernel entry 21 Implementation of Invocation Mechanisms Most invocation middleware (Corba, Java RMI, HTTP) is implemented over TCP For universal availability, unlimited message size and reliable transfer; see section 4.4 for further discussion of the reasons. Sun RPC (used in NFS) is implemented over both UDP and TCP and generally works faster over UDP Research-based systems have implemented much more efficient invocation protocols, e.g. Firefly RPC (see www.cdk3.net/oss) Amoeba's dooperation, getrequest, sendreply primitives (www.cdk3.net/oss) LRPC [Bershad et. al. 1990], described on pp. 237-9).. Concurrent and asynchronous invocations middleware or application doesn't block waiting for reply to each invocation 22 11

Invocations between Address Spaces (a) System call Thread Control transfer via trap instruction User Kernel Control transfer via privileged iil dinstructions ti (b) RPC/RMI (within one computer) Protection domain (an execution environment) boundary Thread 1 Thread 2 User 1 Kernel User 2 (c) RPC/RMI (between computers) Thread 1 Network Thread 2 User 1 User 2 Kernel 1 Kernel 2 23 RPC Delay against Parameter Size RPC delay OS cost 0 1000 2000 Requested data size (bytes) Packet size An RPC fetches a specified amount of data from a server Roughly proportional to the size until meeting a threshold; multiple packets will be involved 24 12

Invocation within a Computer Uses shared memory for inter-process communication Many cross-address-space invocations take place with a computer arguments four times for conventional RPC (could be copied only once) (b) RPC/RMI (within one computer) Protection domain (an execution environment) boundary Thread 1 Thread 2 (c) RPC/RMI (between computers) User 1 Kernel User 2 Cross-address-space Thread 1 Network Thread 2 User 1 User 2 Kernel 1 Kernel 2 25 Bershad's LRPC: A Lightweight Remote Procedure Call LRPC: underlying communication happens to be local Client Server A stack A 1. Copy args 4. Execute procedure and copy results User stub stub Kernel 2. Trap to Kernel 3. Upcall 5. Return (trap) 26 13

Asynchronous RPC 2-12 a) The interconnection between client and server in a traditional RPC b) The interaction using asynchronous RPC 27 Deferred Synchronous RPC A client and server interacting through two asynchronous RPCs 2-13 28 14

One-Way RPC Client Server dooperation Request message getrequest (continuation) Request-reply communication: Synchronous (blocking dooperation) vs. asynchronous communication CORBA one-way RPC invocations have maybe semantics 29 Times for Serialized and Concurrent Invocations Figure 6.14 process args marshal Send Receive unmarshall process results process args marshal Send Serialized invocations transmission Receive unmarshal execute request marshal Send Receive unmarshal execute request marshal Send process args marshal Send process args marshal Send Receive unmarshall process results Receive unmarshal process results Concurrent invocations Receive unmarshal execute request marshal Send Receive unmarshal execute request marshal Send time Receive unmarshal process results Client Server 30 Client Server 15

Monolithic Kernel and Microkernel S4... S1 S2 S3... Kernel S1 S2 S3 S4... Kernel Monolithic Kernel Microkernel Middleware Language Language OS emulation support subsystem support subsystem subsystem Microkernel Hardware... The microkernel supports middleware via subsystems 31 Advantages and Disadvantages of Microkernel + flexibility and extensibility services can be added, modified and debugged small kernel -> fewer bugs protection of services and resources is still maintained - service invocation expensive - unless LRPC is used - extra system calls by services for access to protected resources 32 16

Relevant Topics Not Covered Mach OS case study (Chapter 18) Halfway to a distributed OS The communication model is of particular interest. It includes: ports that can migrate between computers and processes support for RPC typed messages access control to ports open implementation of network communication (drivers outside the kernel) Thread programming g (Section 6.4, and many other sources) e.g. Doug Lea's book Concurrent Programming in Java, (Addison Wesley 1996) 33 Summary The OS provides local support for the implementation of distributed applications and middleware: Manages and protects system resources (memory, processing, communication) Provides relevant local abstractions: files, processes threads, communication ports Middleware provides general-purpose distributed abstractions RPC, RMI, event notification Invocation performance is important it can be optimized, E.g. Firefly RPC, LRPC Microkernel architecture for flexibility The KISS principle ('Keep it simple stupid!') has resulted in migration of many functions out of the OS 34 17