operating system support
TRANSCRIPT
Chapter 7
Operating System Support
© 2015 Prof. Amr El-Kadi 1
Outline
• Introduction
• The operating system layer
• Processes and threads
• Communication and invocation
• Operating system architecture
© 2015 Prof. Amr El-Kadi 2
System layers
Applications, services
Computer &
Platform
Middleware
OS: kernel,libraries & servers
network hardware
OS1
Computer & network hardware
Node 1 Node 2
Processes, threads,communication, ...
OS2Processes, threads,communication, ...
© 2015 Prof. Amr El-Kadi 3
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 4
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 5
–Examples:
• Cluster computer systems
• V system, Sprite, Globe OS
• WebOS (?)
© 2015 Prof. Amr El-Kadi 6
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 7
Core OS functionality
Communication
manager
Thread manager Memory manager
Supervisor
Process manager
© 2015 Prof. Amr El-Kadi 8
Copy-on-write – a convenient
optimization
a) Before write b) After write
Shared
frameA's page
table
B's page
table
Process A’s address space Process B’s address space
Kernel
RA RB
RB copied
from RA
© 2015 Prof. Amr El-Kadi 9
Threads concept and
implementationProcess
Thread activations
Activation stacks
(parameters, local variables)
'text' (program code)Heap (dynamic storage,
objects, global variables)
system-provided resources
(sockets, windows, open files)
© 2015 Prof. Amr El-Kadi 10
Client and server with threads
Server
N threads
Input-output
Client
Thread 2 makes
T1
Thread 1
requests to server
generates
results
Requests
Receipt &queuing
© 2015 Prof. Amr El-Kadi 11
Alternative server threading
architectures
a. Thread-per-request b. Thread-per-connection c. Thread-per-object
remote
workers
I/O remoteremote I/O
per-connection threads per-object threads
objects objectsobjects
© 2015 Prof. Amr El-Kadi 12
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 13
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 14
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 15
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 16
Invocations between address
spacesControl transfer viatrap instruction
User Kernel
Thread
User 1 User 2
Control transfer viaprivileged instructions
Thread 1 Thread 2
Protection domainboundary
(a) System call
(b) RPC/RMI (within one computer)
Kernel
(c) RPC/RMI (between computers)
User 1 User 2
Thread 1 Network Thread 2
Kernel 2Kernel 1
© 2015 Prof. Amr El-Kadi 17
RPC delay against parameter
size
1000 2000
RPC delay
Requested data
size (bytes)
Packet
size
0
© 2015 Prof. Amr El-Kadi 18
Times for serialized and
concurrent invocations
execute request
Send
Receiveunmarshal
marshal
Receiveunmarshal
process results
marshalSend
process args
marshalSend
process args
transmission
Receiveunmarshal
process results
execute request
Send
Receiveunmarshal
marshal
Client Server
Serialized invocations
Client Server
marshalSend
process args
marshalSend
process args
execute request
Send
Receiveunmarshal
marshal
execute request
Send
Receiveunmarshal
marshalReceive
unmarshalprocess results
Receiveunmarshal
process results
time
Concurrent invocations
© 2015 Prof. Amr El-Kadi 19
Monolithic kernel and
microkernel
Monolithic Kernel Microkernel
Server: Dynamically loaded server program:Kernel code and data:
.......
.......
Key:
S4
S1 .......
S1 S2 S3
S2 S3 S4
© 2015 Prof. Amr El-Kadi 20
Middleware
Language
support
subsystem
Language
support
subsystem
OS emulation
subsystem....
Microkernel
Hardware
© 2015 Prof. Amr El-Kadi 21
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 22
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 23
A lightweight remote procedure
call
1. Copy args
2. Trap to Kernel
4. Execute procedure
and copy results
Client
User stub
Server
Kernel
stub
3. Upcall 5. Return (trap)
AA stack
24
Figure 7.17
The architecture of Xen
24
25
Figure 7.18
Use of rings of privilege
25
26Instructor’s Guide for Coulouris, Dollimore, Kindberg and Blair, Distributed Systems: Concepts and Design Edn. 5
© Pearson Education 2012
Figure 7.19
Virtualization of memory
management
26
27
Figure 7.20
Split device drivers
27
28
Figure 7.21
I/O rings
28
29
Figure 7.22
The XenoServer Open Platform
Architecture
29