ppt

advertisement
The Structuring of Systems
Using Upcalls
David D. Clark
4/26/2011
Frank Sliz, CS533, Upcalls
1
Overview
• A method for implementing layers with
synchronous procedure calls between layers
• Upcalls – flow of control by a lower layer
calling an upper layer via procedure call
• Multi-task module – subroutines in different
tasks that make up the layer
4/26/2011
Frank Sliz, CS533, Upcalls
2
Outline
•
•
•
•
•
•
•
Background
Upcalls and Multi-task Modules
Example
Advantages
Swift Operating System
Problems
Conclusions
4/26/2011
Frank Sliz, CS533, Upcalls
3
Background
• 1968 – THE operating system
• Great interest in using layers to structure OS
• 1982 – ISO model for network communication
• 1985 – Swift operating system
4/26/2011
Frank Sliz, CS533, Upcalls
4
Monolithic Operating System
4/26/2011
Frank Sliz, CS533, Upcalls
5
Layered Operating System
4/26/2011
Frank Sliz, CS533, Upcalls
6
Advantages of Layered OS
•
•
•
•
•
•
Modularity
Easier to test and debug
Easier to modify
Acyclic dependency
Verification
Trustworthiness
4/26/2011
Frank Sliz, CS533, Upcalls
7
7-Layer OSI Model
7
application
6 presentation
6
1
4/26/2011
5
session
4
transport
3
network
2
data link
1
physical
Frank Sliz, CS533, Upcalls
8
Disadvantages of Layered OS
• Performance
– Asynchronous communication between layers
– Buffering of data between layers
– Copying of data for crossing protection boundary
– Programming complexity
• Inefficient support for upward flow of control
4/26/2011
Frank Sliz, CS533, Upcalls
9
Upcalls and Multi-Task Modules
• Upcalls
– Flow of control by a lower layer calling an upper
layer via procedure call
• Multi-Task Modules
– Subroutines in different tasks that make up the
layer
– Subroutines are callable from above or below via
procedure calls
– State variables in shared memory
4/26/2011
Frank Sliz, CS533, Upcalls
10
System Organization
4/26/2011
Frank Sliz, CS533, Upcalls
11
Example - Network Protocol
3 Layers and 3 Tasks
Display
Transport
Network
Create
4/26/2011
Receive
Frank Sliz, CS533, Upcalls
Send
12
Control Flow in Network Protocol
Display
Layer
Transport
Layer
Network
Layer
4/26/2011
Frank Sliz, CS533, Upcalls
13
Example - Display Layer
Network Protocol
4/26/2011
Frank Sliz, CS533, Upcalls
14
Example - Transport Layer
Network Protocol
4/26/2011
Frank Sliz, CS533, Upcalls
15
Example Network Layer
Network Protocol
4/26/2011
Frank Sliz, CS533, Upcalls
16
Example – Create Task
4/26/2011
Frank Sliz, CS533, Upcalls
17
Example – Receive Task
4/26/2011
Frank Sliz, CS533, Upcalls
18
Example – Send Task
4/26/2011
Frank Sliz, CS533, Upcalls
19
Advantages of Upcalls
• Upward, synchronous flow via procedure call
is more efficient than IPC
• No need for data buffering between layers
• Simplicity of implementation
• Lower layer can ask advice from upper layer
resulting in simplification of algorithm
4/26/2011
Frank Sliz, CS533, Upcalls
20
Advantages of Multi-Task Modules
• Subroutine interfaces are easier to deal with
than IPC interfaces
• No system wide IPC message format needed
• Decisions about task usage can be made later,
the tasks are not hard coded into the layers
• Acknowledgements can be sent with new
data packet - Piggybacking
4/26/2011
Frank Sliz, CS533, Upcalls
21
Swift Operating System
•
•
•
•
•
•
Explore upcall and multi-module usage
Single address space with a typesafe language
Monitor locks for access to shared state
Initially used for network protocols
Test to determine if useful in other contexts
Develop solutions for upcall problems
4/26/2011
Frank Sliz, CS533, Upcalls
22
Problems with Upcall
• Violates basic principle of layering
– upcall failure could leave lower layer left in
unstable condition
• Recovery of resources when an upcall fails
• Upcall gets into an infinite loop
4/26/2011
Frank Sliz, CS533, Upcalls
23
Mitigating Upcall Failures
• 2 classes of data
– Client or private data which is expendable
– Data shared between tasks must be unlocked and
consistent before upcall
• Expendable tasks
• Layer-specific cleanup via system procedures
• Timer or User to detect infinite loop
4/26/2011
Frank Sliz, CS533, Upcalls
24
Solutions to Indirect Recursive Call
• Put state variables in consistent state before
upcall and then reevaluate them upon return
• Prohibit recursive downcall – variables can be
left locked and inconsistent when upcalling
• Downcall queues the work for later execution
• Downcall is restricted in its actions
• Downcall is replaced by extra arguments or it
is replaced by a second upcall to query
4/26/2011
Frank Sliz, CS533, Upcalls
25
Problems with Multi-Task Modules
• Failure to use monitor locks properly which
can cause incorrect results
• With single shared memory address space
program bugs can corrupt memory
• Need queues for suspended tasks waiting to
obtain monitor locks
4/26/2011
Frank Sliz, CS533, Upcalls
26
Conclusions
• Methodology is useful for operating systems
– upcalls and multi-task modules are efficient
– Strongly checked typesafe language should be
used in a single shared address space
– useful for network protocols, text editors, and I/O
• Bad idea to implement a layer as a process
• Parallel systems need shared memory for
efficient communication between processes
4/26/2011
Frank Sliz, CS533, Upcalls
27
Download