The Structuring of Systems Using Upcalls David D. Clark 4/26/20111Frank Sliz, CS533, Upcalls.

27
The Structuring of Systems Using Upcalls David D. Clark 4/26/2011 1 Frank Sliz, CS533, Upcalls
  • date post

    22-Dec-2015
  • Category

    Documents

  • view

    216
  • download

    0

Transcript of The Structuring of Systems Using Upcalls David D. Clark 4/26/20111Frank Sliz, CS533, Upcalls.

Page 1: The Structuring of Systems Using Upcalls David D. Clark 4/26/20111Frank Sliz, CS533, Upcalls.

The Structuring of SystemsUsing Upcalls

David D. Clark

4/26/2011 1Frank Sliz, CS533, Upcalls

Page 2: The Structuring of Systems Using Upcalls David D. Clark 4/26/20111Frank Sliz, CS533, Upcalls.

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

Page 3: The Structuring of Systems Using Upcalls David D. Clark 4/26/20111Frank Sliz, CS533, Upcalls.

Outline

• Background• Upcalls and Multi-task Modules• Example• Advantages• Swift Operating System• Problems• Conclusions

4/26/2011 Frank Sliz, CS533, Upcalls 3

Page 4: The Structuring of Systems Using Upcalls David D. Clark 4/26/20111Frank Sliz, CS533, Upcalls.

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

Page 5: The Structuring of Systems Using Upcalls David D. Clark 4/26/20111Frank Sliz, CS533, Upcalls.

Monolithic Operating System

4/26/2011 Frank Sliz, CS533, Upcalls 5

Page 6: The Structuring of Systems Using Upcalls David D. Clark 4/26/20111Frank Sliz, CS533, Upcalls.

Layered Operating System

4/26/2011 Frank Sliz, CS533, Upcalls 6

Page 7: The Structuring of Systems Using Upcalls David D. Clark 4/26/20111Frank Sliz, CS533, Upcalls.

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

Page 8: The Structuring of Systems Using Upcalls David D. Clark 4/26/20111Frank Sliz, CS533, Upcalls.

7-Layer OSI Model

4/26/2011 Frank Sliz, CS533, Upcalls 8

application

presentation

session

transport

network

data link

physical

561

7

4

6

2

3

1

Page 9: The Structuring of Systems Using Upcalls David D. Clark 4/26/20111Frank Sliz, CS533, Upcalls.

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

Page 10: The Structuring of Systems Using Upcalls David D. Clark 4/26/20111Frank Sliz, CS533, Upcalls.

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

Page 11: The Structuring of Systems Using Upcalls David D. Clark 4/26/20111Frank Sliz, CS533, Upcalls.

System Organization

4/26/2011 Frank Sliz, CS533, Upcalls 11

Page 12: The Structuring of Systems Using Upcalls David D. Clark 4/26/20111Frank Sliz, CS533, Upcalls.

Example - Network Protocol3 Layers and 3 Tasks

4/26/2011 Frank Sliz, CS533, Upcalls 12

Display

Transport

Network

Create Receive Send

Page 13: The Structuring of Systems Using Upcalls David D. Clark 4/26/20111Frank Sliz, CS533, Upcalls.

Control Flow in Network Protocol

4/26/2011 Frank Sliz, CS533, Upcalls 13

Transport Layer

Display Layer

Network Layer

Page 14: The Structuring of Systems Using Upcalls David D. Clark 4/26/20111Frank Sliz, CS533, Upcalls.

Example - Display LayerNetwork Protocol

4/26/2011 Frank Sliz, CS533, Upcalls 14

Page 15: The Structuring of Systems Using Upcalls David D. Clark 4/26/20111Frank Sliz, CS533, Upcalls.

Example - Transport LayerNetwork Protocol

4/26/2011 Frank Sliz, CS533, Upcalls 15

Page 16: The Structuring of Systems Using Upcalls David D. Clark 4/26/20111Frank Sliz, CS533, Upcalls.

Example Network LayerNetwork Protocol

4/26/2011 Frank Sliz, CS533, Upcalls 16

Page 17: The Structuring of Systems Using Upcalls David D. Clark 4/26/20111Frank Sliz, CS533, Upcalls.

Example – Create Task

4/26/2011 Frank Sliz, CS533, Upcalls 17

Page 18: The Structuring of Systems Using Upcalls David D. Clark 4/26/20111Frank Sliz, CS533, Upcalls.

Example – Receive Task

4/26/2011 Frank Sliz, CS533, Upcalls 18

Page 19: The Structuring of Systems Using Upcalls David D. Clark 4/26/20111Frank Sliz, CS533, Upcalls.

Example – Send Task

4/26/2011 Frank Sliz, CS533, Upcalls 19

Page 20: The Structuring of Systems Using Upcalls David D. Clark 4/26/20111Frank Sliz, CS533, Upcalls.

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

Page 21: The Structuring of Systems Using Upcalls David D. Clark 4/26/20111Frank Sliz, CS533, Upcalls.

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

Page 22: The Structuring of Systems Using Upcalls David D. Clark 4/26/20111Frank Sliz, CS533, Upcalls.

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

Page 23: The Structuring of Systems Using Upcalls David D. Clark 4/26/20111Frank Sliz, CS533, Upcalls.

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

Page 24: The Structuring of Systems Using Upcalls David D. Clark 4/26/20111Frank Sliz, CS533, Upcalls.

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

Page 25: The Structuring of Systems Using Upcalls David D. Clark 4/26/20111Frank Sliz, CS533, Upcalls.

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

Page 26: The Structuring of Systems Using Upcalls David D. Clark 4/26/20111Frank Sliz, CS533, Upcalls.

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

Page 27: The Structuring of Systems Using Upcalls David D. Clark 4/26/20111Frank Sliz, CS533, Upcalls.

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