Operating System Support Outline
Total Page:16
File Type:pdf, Size:1020Kb
Chapter 7 Operating System Support Outline • Introduction • The operating system layer • Processes and threads • Communication and invocation • Operating system architecture © 2015 Prof. Amr El-Kadi 1 System layers Applications, services Middleware OS: kernel, OS1 OS2 libraries & Processes, threads, Processes, threads, servers communication, ... communication, ... Platform Computer & Computer & network hardware network hardware Node 1 Node 2 © 2015 Prof. Amr El-Kadi 2 Middleware and the Operating System • Traditional OS's (e.g. early Unix, Windows 3.0) • Network OS's (e.g. modern UNIX, Windows NT) • Middleware implements abstractions that support network-wide programming. © 2015 Prof. Amr El-Kadi 3 What is a distributed OS? • Presents users (and applications) with an integrated computing platform that hides the individual computers. • Has control over all of the nodes (computers) in the network • In a distributed OS, the user doesn't know (or care) where his programs are running. © 2015 Prof. Amr El-Kadi 4 – Examples: • Cluster computer systems • V system, Sprite, Globe OS • WebOS (?) © 2015 Prof. Amr El-Kadi 5 The support required by middleware and distributed applications • OS manages the basic resources of computer systems • It is the task of an operating system to: – raise the programming interface for these resources to a more useful level: – provide the resources needed for (distributed) services and applications to complete their task © 2015 Prof. Amr El-Kadi 6 Core OS functionality Process manager Communication manager Thread manager Memory manager Supervisor © 2015 Prof. Amr El-Kadi 7 Copy-on-write – a convenient optimization Process A’s address space Process B’s address space RB copied from RA RA RB Kernel Shared frame A's page B's page table table a) Before write b) After write © 2015 Prof. Amr El-Kadi 8 Threads concept and implementation Process Thread activations Activation stacks (parameters, local variables) Heap (dynamic storage, 'text' (program code) objects, global variables) system-provided resources (sockets, windows, open files) © 2015 Prof. Amr El-Kadi 9 Client and server with threads Thread 2 makes requests to server Receipt & Input-output queuing Thread 1 generates results T1 Requests N threads Client Server © 2015 Prof. Amr El-Kadi 10 Alternative server threading architectures per-connection threads per-object threads workers I/O remote remote remote I/O objects objects objects a. Thread-per-request b. Thread-per-connection c. Thread-per-object © 2015 Prof. Amr El-Kadi 11 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) • Threads within same process can share data and other resources more conveniently and efficiently (without copying or messages) • Threads within a process are not protected from each other © 2015 Prof. Amr El-Kadi 12 Support for communication and invocation • The performance of RPC and RMI mechanisms is critical for effective distributed systems. – Typical times for 'null procedure call': – Local procedure call< 1 microseconds – Remote procedure call ~ 10 milliseconds – 'network time' (involving about 100 bytes transferred, at 100 megabits/sec.) accounts for only 0.01 millisecond; the remaining delays must be in OS and middleware - latency, not communication time. © 2015 Prof. Amr El-Kadi 13 Factors affecting RPC/RMI performance – marshalling/unmarshalling + operation despatch at the server – data copying:- application -> kernel space -> communication buffers – thread scheduling and context switching:- including kernel entry – protocol processing:- for each protocol layer – network access delays:- connection setup, network latency © 2015 Prof. Amr El-Kadi 14 Implementation of invocation mechanisms • Most invocation middleware (Corba, Java RMI, HTTP) are implemented over TCP – For universal availability, unlimited message size and reliable transfer – Sun RPC (used in NFS) is implemented over both UDP and TCP • Research-based systems have implemented much more efficient invocation protocols – Firefly RPC – Amoeba's doOperation, getRequest, sendReply primitives LRPC © 2015 Prof. Amr El-Kadi 15 Invocations between address spaces (a) System call Thread Control transfer via trap instruction Control transfer via privileged instructions User Kernel Protection domain (b) RPC/RMI (within one computer) 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 © 2015 Prof. Amr El-Kadi 16 RPC delay against parameter size RPC delay Requested data size (bytes) 0 1000 2000 Packet size © 2015 Prof. Amr El-Kadi 17 Times for serialized and concurrent invocations Serialized invocations Concurrent invocations process args process args marshal marshal Send transmission Send process args marshal Receive Send Receive unmarshal unmarshal execute request execute request marshal marshal Send Send Receive unmarshal Receive Receive execute request unmarshal unmarshal marshal process results process results Send process args marshal Receive Send unmarshal process results Receive time unmarshal execute request marshal Send Receive unmarshal process results Client Server © 2015 Prof. Amr El-Kadi Client Server 18 Monolithic kernel and microkernel S4 ....... S1 S2 S3 S4 ....... ....... S1 S2 S3 Monolithic Kernel Microkernel Key: Server: Kernel code and data: Dynamically loaded server program: © 2015 Prof. Amr El-Kadi 19 Middleware Language Language OS emulation support support subsystem .... subsystem subsystem Microkernel Hardware © 2015 Prof. Amr El-Kadi 20 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 © 2015 Prof. Amr El-Kadi 21 Bershad's LRPC • Uses shared memory for interprocess communication – while maintaining protection of the two processes – arguments copied only once (versus four times for conventional RPC) • Client threads can execute server code – via protected entry points only (uses capabilities) • Up to 3 x faster for local invocations © 2015 Prof. Amr El-Kadi 22 A lightweight remote procedure call 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) © 2015 Prof. Amr El-Kadi 23 Figure 7.17 The architecture of Xen 24 24 Figure 7.18 Use of rings of privilege 25 25 Figure 7.19 Virtualization of memory management 26 Instructor’s Guide for Coulouris, Dollimore, Kindberg and Blair, Distributed Systems: Concepts and Design Edn. 5 © Pearson Education 2012 26 Figure 7.20 Split device drivers 27 27 Figure 7.21 I/O rings 28 28 Figure 7.22 The XenoServer Open Platform Architecture 29 29.