Sie sind auf Seite 1von 17

Slides for Chapter 6:

Operating System support

From Coulouris, Dollimore and Kindberg


Distributed Systems:
Concepts and Design
Edition 4, Pearson Education 2005
Figure 6.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

InstructorsGuideforCoulouris,
Figure 6.2
Core OS functionality

Process manager

Communication
manager

Thread manager Memory manager

Supervisor

InstructorsGuideforCoulouris,
Figure 6.3
Address space

2N

Auxiliary
regions

Stack

Heap

Text
0

InstructorsGuideforCoulouris,
Figure 6.4
Copy-on-write

Process As address space Process Bs 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

InstructorsGuideforCoulouris,
Figure 6.5
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

InstructorsGuideforCoulouris,
Figure 6.6
Alternative server threading architectures (see also Figure 6.5)

per-connection threads per-object threads


workers

I/O remote I/O remote


remote
objects objects
objects

a. Thread-per-request b. Thread-per-connection c. Thread-per-object

InstructorsGuideforCoulouris,
Figure 6.7
State associated with execution environments and threads

Executionenvironment Thread
Addressspacetables Savedprocessorregisters
Communicationinterfaces,openfilesPriorityandexecutionstate(suchas
BLOCKED)
Semaphores,othersynchronization Softwareinterrupthandlinginformation
objects
Listofthreadidentifiers Executionenvironmentidentifier
Pagesofaddressspaceresidentinmemory;hardwarecacheentries

InstructorsGuideforCoulouris,
Figure 6.8
Java thread constructor and management methods

Thread(ThreadGroupgroup,Runnabletarget,Stringname)
CreatesanewthreadintheSUSPENDEDstate,whichwillbelongtogroupand
beidentifiedasname;thethreadwillexecutetherun()methodoftarget.
setPriority(intnewPriority),getPriority()
Setandreturnthethreadspriority.
run()
Athreadexecutestherun()methodofitstargetobject,ifithasone,andotherwise
itsownrun()method(ThreadimplementsRunnable).
start()
ChangethestateofthethreadfromSUSPENDEDtoRUNNABLE.
sleep(intmillisecs)
CausethethreadtoentertheSUSPENDEDstateforthespecifiedtime.
yield()
EntertheREADYstateandinvokethescheduler.
destroy()
Destroythethread.

InstructorsGuideforCoulouris,
Figure 6.9
Java thread synchronization calls

thread.join(intmillisecs)
Blocksthecallingthreadforuptothespecifiedtimeuntilthreadhasterminated.
thread.interrupt()
Interruptsthread:causesittoreturnfromablockingmethodcallsuchassleep().
object.wait(longmillisecs,intnanosecs)
Blocksthecallingthreaduntilacallmadetonotify()ornotifyAll()onobject
wakesthethread,orthethreadisinterrupted,orthespecifiedtimehaselapsed.
object.notify(),object.notifyAll()
Wakes,respectively,oneorallofanythreadsthathavecalledwait()onobject.

InstructorsGuideforCoulouris,
Figure 6.10
Scheduler activations

P added
Process Process
A B SA preempted
Process SA unblocked
SA blocked
Kernel

P idle
Virtual processors Kernel
P needed

A. Assignment of virtual processors B. Events between user-level scheduler & kernel


to processes Key: P = processor; SA = scheduler activation

InstructorsGuideforCoulouris,
Figure 6.11
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

InstructorsGuideforCoulouris,
Figure 6.12
RPC delay against parameter size

RPC delay

Requested data
size (bytes)
0 1000 2000
Packet
size

InstructorsGuideforCoulouris,
Figure 6.13
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)

InstructorsGuideforCoulouris,
Figure 6.14
Times for serialized and concurrent invocations

Serialised 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 Client Server

InstructorsGuideforCoulouris,
Figure 6.15
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:

InstructorsGuideforCoulouris,
Figure 6.16
The role of the microkernel

Middleware

Language Language OS emulation


support support subsystem
....
subsystem subsystem

Microkernel

Hardware

The microkernel supports middleware via subsystems

InstructorsGuideforCoulouris,

Das könnte Ihnen auch gefallen