Dispatching Universität Karlsruhe, System Architecture Group

Similar documents
Maximum CPU utilization is obtained by multiprogramming. CPU I/O Burst Cycle Process execution consists of a cycle of CPU execution and I/O wait

Heap Sort. Lecture 35. Robb T. Koether. Hampden-Sydney College. Mon, Apr 25, 2016

Problem Solving as Search - I

SIDDHARTH INSTITUTE OF ENGINEERING & TECHNOLOGY :: PUTTUR (AUTONOMOUS) Siddharth Nagar, Narayanavanam Road QUESTION BANK (DESCRIPTIVE)

SEARCH TREE. Generating the children of a node

Solving Problems by Searching chap3 1. Problem-Solving Agents

Operating instructions Electrical switching facility pco

Uninformed Search (Ch )

CSE 3401: Intro to AI & LP Uninformed Search II

Representation. Representation. Representation. Representation. 8 puzzle.

Uninformed search strategies

SEARCH SEARCH TREE. Node: State in state tree. Root node: Top of state tree

Princess Nora University Faculty of Computer & Information Systems ARTIFICIAL INTELLIGENCE (CS 370D) Computer Science Department

Uninformed Search (Ch )

Algorithms and Data Structures

CONSOLE-320 ENGLISH. 230A: CONSOLE-320 with cable data output Item 230B: CONSOLE-320 with cable + wireless radio data output

Table of Contents. 1 Command Summary...1

Airflow Options for Cisco MDS 9396S SAN Switch

CS 4649/7649 Robot Intelligence: Planning

FIBA Europe Coaching Website. Manual. Practice Section

Roller AC Servo System

Problem Solving Agents

SUPER LEAGUE Season 7. League Rules and Information Guide

Smart Gas Governor. Also consumers having one cylinder need to monitor consumed quantity to be able to place order for a refill.

In this chapter the concepts of authoring BIOS tasks (TSK) will be considered.

Product Overview. Product Description CHAPTER

CENG 466 Artificial Intelligence. Lecture 4 Solving Problems by Searching (II)

GCMSD-Headspace Analysis SOP

In Response to a Planned Power Outage: PPMS EverCool II Shut Down and Re-start Procedure

[CROSS COUNTRY SCORING]

To Logon On to your tee sheet, start by opening your browser. (NOTE: Internet Explorer V. 6.0 or greater is required.)

Ordering with Par Levels

Application Notes. SLP85xD Load Cells

FireHawk M7 Interface Module Software Instructions OPERATION AND INSTRUCTIONS

Dive Planet. Manual. Rev Basic User Interface. 2 How to organize your dives. 3 Statistics. 4 Location Service and Map View.

3PO MECHANICS. There is one game, three referees, but still only one officiating team.

CT PET-2018 Part - B Phd COMPUTER APPLICATION Sample Question Paper

AHE58/59 AC Servo System

CMPUT680 - Winter 2001

[CROSS COUNTRY SCORING]

Robust Task Execution: Procedural and Model-based. Outline. Desiderata: Robust Task-level Execution

(POM )

Culvert Design for Low and High Gradient Streams in the Midwest. Dale Higgins, Hydrologist Chequamegon-Nicolet National Forest

University of MN, Minnesota Nano Center Standard Operating Procedure

Technology. In the My Files [My Files] submenu you can store all the programs that you have made on the NXT or downloaded from your computer.

Uninformed search methods II.

Golf Team Challenge. Product: EA SPORTS PGA TOUR Software Version: Release Date: 10/18/06. Revised 4/21/2009

The pluriscout Software allows you to record live game data and keep track of game progress as well as your scouting entries.

1. Functional description. Application program usage. 1.1 General. 1.2 Behavior on bus voltage loss and bus voltage. 1.

E A C S. Engine Altitude Conditions Simulator. Technical description

ATM 322 Basic Pneumatics H.W.6 Modules 5 7

Operation of the Perkin Elmer TGA-GC/MS

BASIC Z-STACK AND TIME SERIES SCAN ON THE ZEISS LIGHTSHEET Z. 1

Indiana Traffic Signal Hi Resolution Data Logger Enumerations

CSE 3402: Intro to Artificial Intelligence Uninformed Search II

KIT. Small Automatic Water Boosters KIT MODELS

YSC-8330 USER MANUAL XI AN TYPICAL INDUSTRIES CO.,LTD.

Search I. Tuomas Sandholm Carnegie Mellon University Computer Science Department. [Read Russell & Norvig Chapter 3]

CALEFFI. Ball zone valves. series /03 GB

Configuring Bidirectional Forwarding Detection for BGP

OPERATION OF LIQUID PARTICLE COUNTER. GP-B P0045 Rev -

KELCO F60 DIGITAL PUMP CONTROLLER

GolfLogix: Golf GPS. User Guide for: iphone 3G & 3GS. Version 1.0. Software Release 1.0

Module 3 Developing Timing Plans for Efficient Intersection Operations During Moderate Traffic Volume Conditions

Uninformed search methods II.

SPIROVENT VACUUM DEGASSERS

A4 Operation Manual. Fig.1-1 Controller Socket Diagram

OPERATION. Estimated kerf width compensation. HPR260 Manual Gas Instruction Manual 4-9

2. Terms and Definition 2.1 The term SET/GAME refers to a 1v1 game with the following setting:

Ultimate 101. Calvin Wheeler Hayden Weaver

ZIPWAKE DYNAMIC TRIM CONTROL SYSTEM OUTLINE OF OPERATING PRINCIPLES BEHIND THE AUTOMATIC MOTION CONTROL FEATURES

Steltronic Focus. User Manual Manage Focus Tournaments

BUCKET WHEEL RECLAIMERS. AUTHOR: MR. W KNAPPE MAN TAKRAF Fördertechnik GmbH

Scope of the Transit Priority Project

Introduction to Traffic Signal Timing

POM Patch 7. Service Request: OUTREACH-8673: POM help pages are accessed via http instead of https

English. English. Predictive Multi Gas for

A4s Operation Manual

Urban OR: Quiz 2 Solutions (2003) ( 1 ρ 1 )( 1 ρ 1 ρ 2 ) ( 1 12 )( ) σ S ] 24 [ 2 = 60, 2 2 ] ( 2 ) 3

ELIMINATOR COMPETITION DRAG RACE Program Manual Firm Ver 4.11

SIZING THE WELL-X-TROL

Proto Matrix Musashi 3 Upgrade Manual

Synchro Studio 8. Overview. By Ioannis Psarros

Operating Manual. SUPREMA Calibration. Software for Fire and Gas Warning Units. Order No.: /01. MSAsafety.com

Valves. Controllers. Valves Two Types

COMP9414: Artificial Intelligence Uninformed Search

FRDS GEN II SIMULATOR WORKBOOK

NAPERVILLE SUMMER TENNIS LEAGUE RULES Updated: 10/19

OPERATING INSTRUCTIONS FOR

GolfLogix: Golf GPS. User Guide for: BlackBerry Curve. Version 1.0. Software Release , 8330, 8350i, 8800, 8820, 8830, 8900

Online League Management lta.tournamentsoftware.com. User Manual. Further support is available online at

Introduction. AI and Searching. Simple Example. Simple Example. Now a Bit Harder. From Hammersmith to King s Cross

How to achieve fluid traffic

Basic CPM Calculations

YAKUZA SERIES OLED. For the Bob Long Closer, Marq, Vice, and Protege 4C Technology by Extreme Paintball Design LLC, pat pend FEATURES

HOT SPOT MONITOR (HSM)

There are three types of station hunting in IPedge/VIPedge:

COMP219: Artificial Intelligence. Lecture 8: Combining Search Strategies and Speeding Up

Code of Practice for the Inspection and Testing of Portable Electrical Equipment (PAT)

Pilot Check Valve: Metal Body Type

Transcription:

µ-kernel Construction (6) Dispatching 1

Dispatching Topics Thread switch To a specific thread To next thread to be scheduled To nil Implicitly, when IPC blocks Priorities Preemption Time slices Wakeups, interruptions Timeouts and wakeups Time 2

Thread A Switch to () Dispatcher Thread Smaller stack per thread Dispatcher is preemptible Clean model Improved interrupt latency if dispatching is time consuming switch to (dispatcher) select next ready thread, assume B switch to (B) Thread B 3

Thread A Switch to () save live registers and IP on stack ; tcb[a].sp := SP ; SP := dispatcher stack bottom ; return to dispatcher. switch to (dispatcher) switch to (B) Dispatcher Thread select next ready thread, assume B Dispatcher thread is special No user mode No own AS, hence no AS switch required No ID required Freedom from TCB layout conventions Almost stateless (see priorities) No need to preserve internal state between invocations External state must be consistent costs (A B) costs (A disp B) costs (select next) costs (A disp A) are low Thread B Why?? if B A then switch from AS(A) to AS(B) fi ; SP := tcb[b].sp ; return to B. 4

Example: Simple Dispatch sp Enter the kernel, save some user state in HW Save remaining user state Optionally do some work Save live registers (required when resuming) and return address Store SP in TCB Switch to dispatcher stack Jump to dispatcher code Select next thread to run TCB(A) sp live regs local state eax ebp x cs flg esp ss Dispatcher stack local state 5

Example: Simple Dispatch (cont d) sp Dispatcher selected next thread to run (B) Switch to B s stack Return to B Pop return address from stack Restore live registers Return to B s user mode Pop return address Switch to B s address space (if current) Load user register contents Drop exception code X iret pops remaining data TCB(B) sp live regs local state eax ebp x cs flg esp ss TCB(A) sp live regs local state eax ebp x cs flg esp ss Dispatcher stack local state 6

Example: Simple Dispatch (cont d) Stack layout depends on cause of prior thread switch Timer vs. device IRQ, IPC send vs. recv, yield(), TCB(E) sp live regs local state x cs flg esp ss TCB(D) sp eax ebp x cs flg esp ss TCB(C) sp live regs local state eax ebp x cs flg esp ss TCB(B) sp live regs local state eax ebp x cs flg esp ss TCB(A) sp live regs local state eax ebp x cs flg esp ss Dispatcher stack local state 7

Example: Dispatch with `Tick Dispatcher interrupted by timer IRQ sp Detect and resume Data structures (ready queues) might have changed! Throw away dispatcher state and restart TCB(B) sp live regs local state eax ebp x cs flg esp ss TCB(A) sp live regs local state eax ebp x cs flg esp ss Dispatcher stack local state eax ebp x cs flg esp ss local state 8

Example: Dispatch with Device IRQ Dispatcher interrupted by device IRQ sp Determine handler thread (B) Switch to B (assuming high priority) Throws away dispatcher state TCB(B) sp live regs local state eax ebp x cs flg esp ss TCB(A) sp live regs local state eax ebp x cs flg esp ss Dispatcher stack local state eax ebp x cs flg esp ss local state 9

Switch to () Dispatcher thread is also idle thread Thread A Dispatcher Thread switch to (dispatcher) select next ready thread, assume B switch to (B) B := A ; do B := next ready (B) ; if B nil then return fi ; idle od. Thread B 10

Priorities 0 (lowest) 255 Hard priorities Dynamically changeable Round robin per priority Ready TCB per priority Current TCB per do p := 255 ; do if current [p] nil then B := current [p] ; return fi ; p -= 1 until p < 0 od ; idle od. disp table Prio 100 Prio 50 11

Priorities Optimizations Remember highest active priority Bitmask do p if := current 255 [highest ; active p] nil then dob := current [highest active p] ; if return current [p] nil then elif highest B := current active [p] p ; > 0 then highest return active p -= 1 else fi ; p idle -= 1 until fi p < 0 od ; od idle. od. disp table Prio 100 Prio 50 12

Optimization: Priorities Bitmap Set bit on insertion Clear when group empty IA-32: BSR BIT SCAN REVERSE 2 cycles 240-255 224-239 208-223 32-47 16-31 0-15 13

Priorities, Preemption highest active p := max (new p, highest active p). do do p := 255; if current do [highest active p] nil then B := current if current [highest [p] nil active p] ; return then B := current [p] ; elif highest active p > 0 then return highest active p -= 1 fi ; else p -= 1 idle until p < 0 od ; fi idle od. od disp table Prio 110 Prio 100 Prio 50 p=110 intr/wakeup 14

Priorities, Preemption What happens when a priority falls empty? do if current [highest active p] nil then round robin if necessary ; B := current [highest active p] ; return elif highest active p > 0 then do highest active p -= 1 if else current [highest active p] nil then idle B := current [highest active p] ; fi return od elif. highest active p > 0 then highest active p -= 1 round elserobin if necessary: if current idle [hi act p].rem ts = 0 then fi current [hi act p].rem ts := new ts ; od. current [hi act p] := current [hi act p].next ; fi. disp table Prio 110 Prio 100 Prio 50? Remaining time slice > 0? 15

Priorities, Preemption What happens when a priority falls empty? do if current [highest active p] nil then round robin if necessary ; B := current [highest active p] ; return elif highest active p > 0 then highest active p -= 1 else fi od. idle round robin if necessary: if current [hi act p].rem ts = 0 then current [hi act p].rem ts := new ts ; current [hi act p] := current [hi act p].next ; fi. disp table Prio 110 Prio 100 Prio 50 Remaining time slice > 0 16

Preemption Preemption, time slice exhausted do if current [highest active p] nil then round robin if necessary ; B := current [highest active p] ; return elif highest active p > 0 then highest active p -= 1 else fi od. idle round robin if necessary: if current [hi act p].rem ts = 0 then current [hi act p].rem ts := new ts ; current [hi act p] := current [hi act p].next ; fi. disp table Prio 100 Prio 50 Remaining time slice = 0 17

Preemption Preemption, time slice exhausted do if current [highest active p] nil then round robin if necessary ; B := current [highest active p] ; return elif highest active p > 0 then highest active p -= 1 else fi od. idle round robin if necessary: if current [hi act p].rem ts = 0 then current [hi act p].rem ts := new ts ; current [hi act p] := current [hi act p].next ; fi. disp table Prio 100 Prio 50 Remaining time slice := new ts 18

Lazy Dispatching Thread state toggles frequently (per IPC) ready waiting Delete/insert ready is expensive Therefore: delete lazily from ready disp table Prio 100 Prio 50 ready ready ready 19

Lazy Dispatching Thread state toggles frequently (per IPC) ready waiting Delete/insert ready is expensive Therefore: delete lazily from ready disp table Prio 100 Prio 50 ready waiting ready 20

Lazy Dispatching Thread state toggles frequently (per IPC) ready waiting Delete/insert ready is expensive Therefore: delete lazily from ready disp table Prio 100 Prio 50 ready waiting ready 21

Lazy Dispatching Thread state toggles frequently (per IPC) ready waiting Delete/insert ready is expensive Therefore: delete lazily from ready disp table Prio 100 Prio 50 ready waiting ready 22

Lazy Dispatching Thread state toggles frequently (per IPC) ready waiting Delete/insert ready is expensive Therefore: delete lazily from ready Whenever reaching a non-ready thread Delete it from Proceed with next disp table Prio 100 ready ready Prio 50 23

Lazy Dispatching do round robin if necessary ; if current [highest active p] nil then Thread state toggles return frequently (per IPC) B := current [highest active p] ; return elif highest active p > 0 then highest active readyp -= 1 waiting else idle fi od. Delete/insert ready is expensive Therefore: delete lazily from ready Whenever reaching a non-ready thread Delete it from round robin if necessary: while current [hi act p] nil do next := current [hi act p].next ; if current [hi act p].state ready then delete from (current [hi act p] ) elif current [hi act p].rem ts = 0 then current [hi act p].rem ts := new ts else return fi ; current [hi act p] := next od. Proceed with next disp table 24 Prio 100 Prio 50 ready ready

Timeouts & Wakeups Operations Insert timeout Raise timeout Find next timeout Delete timeout timeout set completion, no timeout timeout expired t Raised-timeout costs are uncritical (occur only after timeout exp time). Most timeouts are never raised! 25

Timeouts & Wakeups too expensive Idea 1: unsorted Insert timeout costs Prepend entry 20..100 cycles Find next timeout t costs Parse entire n 10..50 cycles Raise timeout costs Delete timeout costs Delete known entry 20..100 cycles 26

Timeouts & Wakeups too expensive Idea 2: sorted Insert timeout costs Search + insert n/2 10..50 + 20..100 cycles Find next timeout t costs Check head 10 cycles Raise timeout costs Delete timeout costs Delete known entry 20..100 cycles 27

Timeouts & Wakeups Idea 3: sorted tree / heap too expensive too complicated Insert timeout costs Search + insert log n 10..50 + 20..100 cycles Find next timeout t costs Find min node / root log n x 10..50 / 10 cycles Raise timeout costs Delete timeout costs Delete known node log n x 10..50 + 20..100 / log n x 20..100 28

Wakeup Classes now insert timeout (now + ) soon late late late now soon t late late late 29

Wakeup Classes now soon late late late now soon t late late late 30

Wakeup Classes now soon late late late soon t late late contains soon entries late correction phase required late late 31

Wakeup Classes now soon late late late soon now t late late late late late contains soon and late entries late late correction phase required Also move late late entries to late Postpone further late late correction phases 32

Wakeup Classes now soon soon late late late now soon s := max #entries (length of soon ) t late s #timeouts to be raised in soon + new soon timeouts late late s is small if soon is short enough 33

Timeouts & Wakeups Idea 4: unsorted wakeup classes Insert timeout costs Select class + prepend 10 + 20..100 cycles Find next timeout t costs still Search soon class s 10..50 cycles Raise timeout costs Delete timeout costs Delete known entry 20..100 cycles too expensive Raised-timeout costs are uncritical (occur only after timeout exp time). Most timeouts are never raised! 34

Lazy Timeouts insert (t 1 ) soon late late late t 1 now soon Late t late late 35

Lazy Timeouts insert (t 1 ) delete timeout soon late late late now soon Late t late late 36

Lazy Timeouts insert (t 1 ) delete timeout insert (t 2 ) soon late late late t 2 now soon Late t late late 37