CSE522 Advanced Operating Systems Midterm Review - PowerPoint PPT Presentation

1 / 56
About This Presentation
Title:

CSE522 Advanced Operating Systems Midterm Review

Description:

Design issues: Process/Thread model; Expressing and controlling concurrency; ... No validation or only demonstrate jobs meet some ... Real-Time: System Model ... – PowerPoint PPT presentation

Number of Views:182
Avg rating:3.0/5.0
Slides: 57
Provided by: fredk9
Category:

less

Transcript and Presenter's Notes

Title: CSE522 Advanced Operating Systems Midterm Review


1
CSE522Advanced Operating SystemsMidterm Review
  • Fred Kuhns
  • (fredk_at_cse.wustl.edu, http//www.arl.wustl.edu/fr
    edk)
  • Applied Research Laboratory
  • Department of Computer Science and Engineering
  • Washington University in St. Louis

2
Background
3
Example (Simplified) Systems
4
Instruction Cycle with Interrupts
Fetch Cycle
Execute Cycle
Interrupt Cycle
Interrupts Disabled
Fetch Next Instruction
Execute Instruction
Check for Process Interrupts
START
Interrupts Enabled
HALT
5
I/O and Devices
Processor
Device table
dispatcher (interrupt handler)
X
Bus
command
status
data 0
data 1
Device Controller (firmware and logic)
...
data N-1
Device X
6
Multi-Processor
  • Motivation Enhanced Performance, Fault Tolerance
  • Shared-memory multiprocessor UMA, NUMA
  • communication using shared memory
  • Distributed memory, Multicomputer
  • message passing, tightly coupled, high-speed
    interconnect, No Remote Memory Access (NORMA)
  • Distributed System
  • message passing, loosely coupled, networked
    computers NORMA
  • Interconnection technology
  • Bus, cross-bar, network
  • Caching - Cache Coherence Problem.
  • Write-update, Write-invalidate, Bus snooping
  • Structure
  • Separate Supervisor, Master/Slave, SMP

7
Multi-Processor
  • Design issues Process/Thread model Expressing
    and controlling concurrency Kernel
    Synchronization Task Scheduling Memory
    Management Reliability Fault Tolerance

CPU
CPU
CPU
CPU
500MHz
cache
MMU
cache
MMU
cache
MMU
cache
MMU
System/Memory Bus
I/O subsystem
  • Issues
  • Memory contention
  • Limited bus BW
  • I/O contention
  • Cache coherence

Main Memory
50ns
Bridge
INT
ether
System Functions (timer, BIOS, reset)
scsi
  • Traditional I/O Bus
  • 33MHz/32bit (132MB/s)
  • 66MHz/64bit (528MB/s)

video
8
OS Function
  • Functions of an OS
  • Resource management time and space management
    synchronization and deadlock handling accounting
    and status information
  • User Environment Execution environment error
    detection and handling protection and security
    fault tolerance and failure recovery
  • User friendly Interface System API
  • Three driving concepts
  • Abstraction
  • Virtualization
  • Resource management
  • Design Goals Manage complexity, Separation of
    policy and mechanism
  • Design Approaches Layered, Monolithic kernel,
    Microkernel

9
Historical Perspective UNIX and Monolithic
Kernels
execution environment
application
trap
libraries
user
System call interface
kernel
File subsystem
IPC
System Services
Process control subsystem
Buffer cache
scheduler
memory
hardware
10
Basic Concepts and Terminology
  • Kernel
  • trusted software component, a privileged address
    space and direct access to hardware.
  • Process
  • Fundamental abstraction untrusted application
    software assigned own "protected" address space,
    assigned virtualized resource abstractions.
  • User credentials user id and group id.
  • Two privilege levels, or modes user and system

11
Processing Model
  • Trap and Interrupt processing
  • mechanism for changing from an unprivileged to
    privileged mode (user to system mode)
  • indicates both synchronous and asynchronous
    events
  • fundamentally important for I/O
  • Synchronization
  • re-entrant kernels, interrupt blocking, blocking
    operations
  • Synchronous versus asynchronous operations
  • Scheduling policies
  • Process event notification
  • Process life cycle

12
Traditional Address Space Assignments
13
Process States
14
Historical Perspective THE and Layered Systems
  • Layered Approach
  • Processor Allocation
  • Segment controller
  • Message Interpreter
  • Stream Buffer
  • User programs
  • Operator and Keyboard
  • Relied on semaphores for concurrency control
  • Clean interfaces and isolation between layers
  • Simplified verification and debugging

15
Historical Perspective UNIX and Monolithic
Kernels
  • See earlier discussion

16
Historical Perspective RC 4000 and Microkernels
  • Hansen and the RC 4000 (The Nucleus of a
    Multi-programming System)
  • Dynamic creation of process hierarchies
  • System nucleus
  • Unambiguous definition of the process abstraction
  • Synchronization and IPC
  • Rules governing the dynamic creation, termination
    and control of processes
  • System services (aka policies) implemented by use
    level processes.
  • Primitive operations implemented by trusted
    kernel
  • Communication by message passing between
    processes (internal and external)

17
Historical Perspective Objects, Protection and
Policy
  • Hydra
  • Development of a system software framework for
    defining and implementing operating systems on
    multi-processor systems
  • Generalized the notion of a resource as an
    object, name space, operations and user
    capabilities (for access and control)
  • Goal is to create a basic set of facilities to
    allow for the specification and construction of
    flexible, efficient and reliable systems.

18
Concurrency
  • Properties Safety, Liveness
  • Independent processes Two processes are
    independent if the write set of each is disjoint
    from both the read and write sets of the other.
  • Race condition If two or more process access and
    modify shared data concurrently, and the final
    value of the shared data depends on the order in
    which it was accessed.
  • Critical reference reference to a variable
    changed by another process. Assume the variable
    is written or read atomically.
  • Critical assertion A pre/post condition that is
    not in a critical section.
  • Noninterference An assignment a and its
    precondition pre(a) in process A does not
    interfere with a critical assertion C in another
    process if the following is always true. C
    pre(a) a CThat is, C is not affected by the
    execution of a when pre(a) is true.

19
Avoiding Race Conditions
  • At-Most-Once property If the assignment
    statement x e satisfies
  • e contains at most one critical reference and x
    is not read by another process or
  • e contains no critical references, in which case
    x may be read by another process.
  • In other words, there can be at most one
    critical reference within the expression S x e

20
Critical Section Problem
  • Entry/exit protocol satisfies
  • Mutual Exclusion At most one process may be
    active within the CS
  • Absence of deadlock (livelock) if two or more
    processes attempt to enter CS, at least one will
    succeed.
  • 2 or more processes must not enter into infinite
    loops or other forms of deadlock/livelock.
  • Absence of Unnecessary delay If a process
    attempts to enter CS and the other processes are
    either in their non-critical sections or have
    terminated then the process is not prevented from
    entering the CS.
  • processes neither operating in or attempting to
    enter CS can prevent another process from
    entering CS.
  • Eventual entry (no starvation, more a function of
    scheduling) A process attempting to enter CS
    will eventually succeed.
  • One process may not repeatedly enter CS while
    another process waits

Assumption A process that enters its critical
section will eventually exit.
Task A while (True) entry
protocol critical section exit
protocol non-critical section
Safety Properties
Liveness Property
21
Mutual Exclusion
  • Single Processor versus Multi-processor
  • Locked/Waiting (Blocking)
  • Wait channels
  • Multi-Processor
  • Hardware support for atomic operations
  • spin-locks and Busy waiting
  • Semaphores mutual exclusion event notification
    and resource counting.
  • As locks ownership transfers to thread when
    woken.
  • Considerations
  • Efficiency of synchronization operations/abstracti
    ons
  • Lost wakeup problem
  • Thundering heard problem
  • Convoys
  • Know example implementations

22
Synchronization Mechanisms - continued
  • Condition variables event notification, usually
    has an associated predicate and lock to protect
    predicate. Know proper use, example
    implementation and the difference between
    signal-and-wait and signal-and-continue
    semantics.
  • Read/Write Locks Understand the different
    possible behaviors with respect to readers and
    writes.
  • Reference Counting Protects object when there
    are outstanding references
  • Considerations
  • Deadlock avoidance Recursive Locks Adaptive
    Locks (Mutex)
  • Protecting invariants, predicates, data,
    operations (monitors).
  • Granularity and Duration.

23
Inter-Process Communication
  • Mechanisms message passing shared memory
  • Message passing
  • Processes must establish a communication channel
  • Communication channel can be thought of as a
    queue of messages that have been sent but not yet
    read
  • Message passing facility defines two operations
    on a communication channel send(channel,
    message) and recv(channel, message)
  • Methods for implementing a logical communication
    link and primitives (send/receive)
  • Direct or Indirect communications (Naming)
  • Symmetric or Asymmetric communications
  • Automatic or Explicit buffering
  • Send-by-copy or send-by-reference
  • fixed or variable sized messages
  • Purposes of IPC Data Transfer Sharing Data
    Event notification Resource Sharing Process
    Control
  • Review MACH IPC

24
Universal IPC Facilities
handler
user
process 2
dbx
kernel
stop
handle event
25
Threads
  • Process encompasses
  • set of threads (computational entities)
  • collection of resources (i.e. resource ownership)
  • Thread Dynamic object representing an execution
    path and computational state.
  • separate the notion of execution from the Process
    abstraction
  • Advantages
  • Exploit multi-processor environments
  • Expressing the intrinsic concurrency of a program
    regardless of resulting performance
  • Three types User threads, kernel threads and
    Light Weight Processes (LWP)
  • Mach Continuations
  • Events versus Threads

26
Scheduling
  • Multiprogrammed Operating System
  • maximize utilization by multiplexing the CPU
    among competing processes.
  • goal is to always have some process running
  • one process runs until it must wait for some
    event at which point the OS inserts another
    ready process onto the CPU
  • In preemptive schemes a process may also be
    involuntarily suspended so another process may be
    scheduled in its place.
  • Overview of scheduling module
  • Basic Concepts burst cycle, scheduler,
    preemption, dispatcher
  • Scheduling Criteria utilization Throughput
    Turnaround time Waiting time Response time
  • Scheduling Algorithms FIFO (head-of-line
    blocking) Shortest-Job-First (SJF)
    Priority-based Round-robin Multilevel Queue
    Multilevel feedback queue
  • Scheduling Issues, Implementations and
    Mechanisms Interrupt letancy, clock resolution
    cost of context switch
  • General considerations
  • Hidden scheduling Priority Inversion
  • Know BSD scheduler
  • Gang Scheduling on Mach dedicate one processor
    per thread Minimize barrier synchronization
    delay

27
Priority Inheritance
  • Solaris
  • Each thread has a global and inherited priority.
  • Object must keep a reference to the owner
  • If requester priority gt owner, then owner
    priority raised to that of the requesters
  • This works with Mutexes since owner always known
    but not for semaphores or condition variables
  • For reader/writer,
  • owner of record inherits priority, only partial
    solution
  • Mach
  • Inherited base scheduling priority which is
    combined with a CPU usage factor
  • CPU usage factor decayed 5/8 each second inactive
  • threads set own priority after waking up.
  • Clock handler charges current thread.
  • Every 2 seconds, system thread scans run queue
    and recomputes priorities (addresses starvation)
  • Fixed quantums, preemptive scheduling
  • handoff scheduling - used by IPC

28
Real-Time Terminology
  • Timing constraint constraint imposed on timing
    behavior of a job hard or soft.
  • Release Time Instant of time job becomes
    available for execution. If all jobs are
    released when the system begins execution, then
    there is said to be no release time.
  • Deadline Instant of time a job's execution is
    required to be completed. If deadline is
    infinity, then job has no deadline. Absolute
    deadline is equal to release time plus relative
    deadline.
  • Response time Length of time from release time
    to instant job completes.
  • Hard failure to meet constraint is a fatal
    fault. Validated system always meets timing
    constraints (deterministic, probabilistic,
    utility function)
  • Soft late completion is undesirable but
    generally not fatal. No validation or only
    demonstrate jobs meet some statistical
    constraint. Occasional missed deadlines or
    aborted execution is (usually) considered
    tolerable. Often specified in probabilistic terms
  • Validation Demonstration by a provably correct,
    efficient procedure or by exhaustive simulation
    and testing. Involves three steps consistent
    timing constraints individual components in
    isolation can meet their contraints scheduling
    algorithm produces valid schedule.

29
Real-Time System Model
  • Modeling the system to focus on timing properties
    and resource requirements
  • Workload model - describes supported applications
  • Task model and Temporal parameters
  • Precedence constraints and dependencies
  • Functional parameters
  • Resource model - describes available system
    resources
  • Modeling resources (Processors and Resources)
  • Resource parameters
  • Algorithms - how application uses resources at
    all times
  • Scheduling Hierarchy
  • Resources divided into two classes
  • Active resources, or Processors (Pi), execute
    jobs. Examples include CPUs and data links.
  • Passive resource or simply Resource (Ri), are
    generally managed by the system.
  • Tasks and Jobs
  • Task (Ti) Set of related jobs jointly provide
    function.
  • Job (Jij) Unit of work, scheduled and executed
    by system. characterized by Temporal parameters,
    Functional parameters, Resource parameters,
    Interconnection parameters
  • Sporadic Tasks stream of aperiodic or sporadic
    jobs.
  • Jobs within a task have similar statistical
    behavior and timing requirements
  • Assumed system is stationary within the
    hyperperiod

30
Task/Job Parameters
  • Assume periodic task model
  • The number and parameters of all tasks with hard
    timing constraints is known at all times.
  • Task Ti is a serious of periodic Jobs Jij.
  • ?i - phase of Task Ti, equal to ri1
  • rij - release time of the jth Job in Task i (Jij
    in Ti).
  • pi - period, minimum inter-release interval
    between jobs in Task Ti.
  • ei - maximum execution time for jobs in task Ti.
  • Di - relative deadline
  • di - absolute deadline
  • (ri, di - feasible interval
  • ui - utilization of Task Ti and is equal to
    ei/pi.
  • System Parameters
  • H - Hyperperiod Least Common Multiple of pi for
    all i H lcm(pi), for all i. The number of jobs
    in a hyperperiod is equal to the sum of (H/pi)
    over all i.
  • U - Total utilization Sum over all ui.

31
Task/Job Parameters
  • Functional Parameters
  • Preemptivity
  • Criticality (Useful during overload)
  • Optional Executions (Useful during overload)
  • Laxity (Useful during overload)
  • Precedence Constraints and Task Graphs
  • Jobs are either precedence constrained or
    independent.
  • Precedence relation partial ordering operator lt
  • JiltJkJi is predecessor of Jk, Jk is successor of
    Ji
  • A job is ready when both the time gt its release
    time and all predecessors have completed.
  • Resource Parameters
  • Job resource parameters indicate processor and
    resource requirements
  • Preemptivity of resources.
  • Resource Graph

32
RT-Scheduling
  • Scheduling Paradigms
  • static table-driven - static analysis and
    explicit schedule (table).
  • static priority driven - static analysis, no
    explicit schedule, priorities used at runtime.
  • dynamic planning based - feasibility check at
    run-time, schedule produced. Result includes
    schedule.
  • dynamic best effort - No feasibility check,
    attempts to meet deadlines but no guarantee.
  • Scheduling Algorithms
  • Most instances, scheduling problem is intractable
  • Resource constrained scheduling is NP-complete.
    Precedence constraints aggravate the problem.
  • Heuristics and approximation techniques used to
    handle tasks with complex requirements.

33
Earliest Deadline First (EDF)
  • EDF priority driven scheduling algorithm with
    dynamic task (fixed job) priority assignment.
  • earlier the deadline, higher the priority
  • priorities are assigned on job release
  • Jobs placed in run queue by priority
  • Assumptions
  • Tasks are preemptable and independent
  • Tasks have arbitrary release times, arbitrary
    deadlines
  • Single Processor
  • Optimal EDF can produce a feasible schedule for
    a set of Jobs J if and only if J has a feasible
    schedule.

34
Latest Release Time (LRT)
  • Goes "backwards" in time Treats release times as
    deadlines and deadlines as release times.
  • job with latest release time has highest priority
  • Assume jobs are preemptable
  • May leave processor idle when jobs are ready, so
    not a priority-driven algorithm.
  • Optimal LRT can produce feasible schedule for a
    set of jobs J if and only if feasible schedules
    for J exist.

35
Least Slack Time First (LST)
  • LST or Maximum Laxity First (MLF)
  • Dispatch job with minimum slack time smaller
    slack time, higher priority.
  • Optimal Can produce feasible schedules for J if
    and only if feasible schedules for J exist.
  • Requires knowledge of execution times, while EDF
    does not.
  • Consequently may underutilize processor when
    using maximum (worst-case) analysis.

36
Static Strategies
  • Table Driven
  • Typically applied to systems with safety critical
    requirements.
  • Resources preallocated to tasks so that they can
    meet their deadlines
  • Assume tasks are periodic
  • feasible schedule iff there exists a feasible
    schedule for the Hyperperiod
  • Rate monotonic (RM) or Earliest deadline first
    (EDF) scheduling algorithms can be used for
    systems with simple characteristics.
  • Complicated by resource requirements along with
    precedence, exclusion, communication and
    replication constraints.
  • Priority-Driven
  • Assigning priority based on RM and EDF.
  • single processor, periodic tasks, preemption
  • RM static priorities based on period.
  • EDF dynamic priority based on deadline.
  • Advantage is that schedulability analysis based
    only on utilization constraints.
  • May assign priority based on laxity, LLF Least
    Laxity First
  • May assign priority based on any of the tasks
    parameters
  • Preemptive scheduling may simplify analysis but
    overhead needs to be considered.
  • scheduling algorithm
  • task dispatcher
  • context switch overhead

37
Dynamic Strategies
  • Planning based (for example priority driven)
  • Dynamic feasibility checks
  • Must consider worst case execution times,
    resource requirements, timing constraints,
    periodic tasks, preemption, precedence
    constraints, importance levels and fault
    tolerance
  • If task arrival times are not known a priori,
    cannot guarantee performance
  • Various heuristic algorithms for scheduling tasks
    in a distributed environment.
  • Best-effort based (for example Weighted Round
    Robin)
  • Used by many systems system computes task
    priorities and schedules accordingly. Extensive
    simulations are used to gain confidence in
    behavior
  • May compensate for other priority driven
    algorithms (RM) which perform poorly in overload
    conditions
  • May use a value function to schedule during
    overload maximize sum of task values. May also
    discard low value tasks
  • Priority-driven preemptive scheduling
  • shortest processing time, EDF, least laxity
    first, FCFS, random selection,.
  • Discard tasks with lowest value function

38
Clock Driven
  • Know advantages and disadvantages
  • Know example implementation of cyclic executive
  • Know how to calculate the Hyperperiod
  • 1) f max(ei), 1i n
  • 2) f divides pi for at least one value of i
  • 3) Between the release time and deadline of
    every job there is at least one frame 2f -
    gcd(pi, f) Di

Major Cycle
Minor Cycle (frame)
...
T1
T2
T3
T1
T4
T1
T2
T3
f2
fn
f1
Cyclic Executive runs in response to a tick
event, bar shows time to execute scheduler
39
Slack Stealing
  • Scheduling aperiodic jobs with periodic jobs
  • Foreground jobs gt periodic jobs already
    discussed
  • background jobs gt aperiodic jobs
  • Aperiodic jobs executed within the idle blocks
    and are preemptable
  • May optimize response time by scheduling within
    slack time (slack stealing).
  • Slack f xk where xk total time allocated
    to periodic tasks in frame k and f frame size
  • Requirements may include some minimal aperiodic
    arrival rate
  • Cyclic Exec executes aperiodic jobs as long as
    there is slack in the schedule. Periodic jobs
    must complete by deadline.

40
Sporadic Jobs
  • Sporadic jobs S(d,e) d deadline, e
    execution time
  • hard deadlines, minimum interrelease times and
    maximum execution time are not known in advance
  • maximum execution time is known on release
  • jobs are preemptable
  • Apply an acceptance test at run time
  • When job is released, determine if there is a
    feasible schedule that includes this sporadic job
  • If no feasible schedule, then reject job and
    notify application of rejection

41
Acceptance test
  • Calculating the available slack time released in
    (x - 1), deadline in frame (y 1)
  • Original slack time between all frame pairs
    within one major cycle, Q(x, y) for x, y in H.
  • Step 1
  • Assume x is in major cycle j and y is in major
    cycle k
  • Q(x,y) Q(x,F) Q(1,y) (k - 1) - jQ(1,F) k
    gt j
  • Q(x, y) is known if k j, y gt x.
  • Decrease available slack time by required
    exectime of higher priority jobs
  • Qc(x, y) Q(x, y) - Sumdk?d (ek - e'k)
  • If S is accepted, Slack before new sporadic job's
    deadline
  • Qs Qc(x, y) e
  • if (Qs lt 0) then reject
  • else store Qs and continue
  • Step 2
  • Check all jobs with deadlines after d to verify
    they will not miss their deadlines.
  • d deadline of new sporadic task e execution
    time of new sporadic task
  • Let Sk accepted sporadic task with deadline dk
    gt d.
  • Let Qk calculated slack for sporadic tasks in
    Sk
  • Accept if Step one is valid and the following
    condition is valid
  • Qk - e ? 0 for all sporadic jobs with dkgtd

42
Periodic Real-Time
  • Event-driven, work-conserving schedulers
  • Jobs assigned explicit or implicit priorities
  • Algorithm defined by priorities used and a set of
    rules (preemption, priority changes etc).
  • Algorithms that consider a jobs urgency generally
    perform better than those that do not.
  • Static versus Dynamic assignment of workloads
  • for now we only consider the case where a set of
    tasks are statically assigned to a processor.
  • Fixed versus Dynamic priority assignment.
  • Fixed priority RM and DM
  • Dynamic Task, Fixed Job EDF
  • Dynamic Job LST (Least Slack First)

43
Periodic Concepts
  • Schedulable Utilization
  • A scheduling algorithm can feasibly schedule any
    set of periodic tasks on a processor if the total
    utilization of the tasks is equal to or less than
    the schedulable utilization of the algorithm
  • Schedulable utilization is necessarily lt 1
  • While dynamic priority algorithms have better
    average performance, they are less predictable
    during overload.
  • Schedulable Utilizations of EDF
  • if Dk ? pk then density ? U, utilization test
    is both necessary and sufficient.
  • if Dk lt pk for some k then the test is only a
    sufficient condition.

44
Fixed Priority Algorithms
  • Rate Monotonic (RM)
  • Priorities based on Task period smaller periods
    have higher priority.
  • if pi lt pk (rate of Ti gt rate of Tk), then ?i gt
    ?k
  • Deadline Monotonic (DM)
  • Priority based on task deadline smaller relative
    deadline, higher priority.
  • if Di lt Dk, then ?i gt ?k
  • No fixed priority algorithmis optimal
  • Among fixed-priorityalgorithms, DMis optimal
  • Under specialcases can achievea utilization of 1

Sufficient Utilization bounds for RM, Dk ?pk
45
Concepts
  • Central concept for fixed priority systems
  • A critical instant of a task is the "instant" in
    time when a job (in Ti) has its maximum response
    time.
  • If a task can be scheduled in its critical
    instant then it will not miss a deadline.
  • Occurs when a job in Ti is released concurrently
    with all higher priority jobs.
  • Time demand analysis
  • Computes total demand for processor time by a job
    released at a critical instant of the task and
    all higher priority tasks.
  • If this worst case response time is less than or
    equal to the jobs deadline, then it is
    schedulable.

for 0 lt t ? pi
46
Critical Instant Time demand analysis
Decreasing the phase ?k shifts the graph up thus
increasing the response time. Likewise,
decreasing the phases of higher priority jobs
(?j) will also increase the jobs response time.
Therefore, the maximum response time of a job
occurs when all jobs are in phase.
W
wk,1 t
?k
t
?j
47
Practical Considerations
  • Blocking due to Non-Preemptive Higher priority
    job is blocked by a lower priority job during a
    nonpreemptive interval resulting in a priority
    inversion.
  • Self Suspension If higher priority job
    self-suspends then its computation time may be
    deferred until the feasible interval for some
    other job
  • Context Switches
  • Limited Priority Levels N task priorities, S
    system priorities and N ! S, then must provide a
    mapping.
  • Tick scheduling A job may wait on scheduling
    queue when runnable
  • Variable priority

48
Practical Considerations
  • Context Switch, assume fixed job priorities.
  • we can account for this by increasing a jobs
    execution time by 2CS or 2(K1)CS if
    self-suspend K times.
  • Updating our tests (must be true for every i)

49
Resource Access Control
  • Goals
  • Bound delay due to Priority Inversion and Timing
    Anomalies
  • Prevent Deadlock
  • Three Examples
  • Nonpreemptive Critical Sections
  • If Ji holds a resource it effectively has the
    highest priority in the system i.e. it will not
    be preempted while holding a resource.
  • No deadlock, No uncontrolled Priority Inversion
  • Priority Inheritance Protocol
  • Deadlock, No uncontrolled Priority Inversion
  • Priority Ceiling Protocol
  • No deadlock, No uncontrolled Priority Inversion

50
Priority Inheritance Rules (PI)
  • Priority-Inheritance Rule
  • if Ji ? Rk ? Jm and ?m(t1-) lt ?i(t1)
  • then ?m(t1) ?i(t1)
  • until Jm releases Rk when ?m(t2) ?m(t1-)
  • Assessment
  • simple and works with any priority driven
    scheduler. Does not require foreknowledge. When
    no deadlock, no unbounded delay.
  • Two types of blocking Direct and Priority
    Inheritance blocking
  • Has the transitive property.
  • Does not result in minimal blocking time
  • Does not prevent deadlock

51
Basic Priority Ceiling Rules
  • Extends PI to prevent deadlock and reduce
    blocking time
  • Assumptions
  • fixed assigned priorities resource requirements
    of tasks known
  • priority ceiling for Rk ?(Rk) max(?i) for all
    Ji requiring Rk
  • System priority ceiling ?(t) max?(Rk) for
    all Rk in use at time t.If no resource in use
    then ?(Rk) ?
  • Allocation Rule (Ji requests Rk at time t t1)
  • if Ji ? Rk ? Jm at t t1 then block Ji (no
    change)
  • else (Rk free at t1) if ?i(t1) gt ?(t), then Rk
    ? Ji else if for some Rx ? Ji and ?(Rx) ?(t1),
    then Rk ? Ji else deny and block (Ji ? Rk)
  • Priority-Inheritance Rule
  • if Ji blocks on resource Rk held by Jm (Ji ?
    Rk) (note Rk?Jm and ?m(t1-)priority of Jm at t
    t1-)then ?m(t1) ?i(t1) (inherited priority)
    until Jm releases all Rx with ?(Rx)??(t1) at t
    t2 , ?m(t2) ?m(t1-)

52
Stack-Based Priority Ceiling Protocol
  • Update Current Ceiling in the usual manner
  • When no resources are held the ?(t) ?
  • otherwise, ?(t) max?(Rk) for all Rk in use
    at time t.
  • Scheduling Rule
  • when Ji released it is blocked until its assigned
    priority ?i(t) gt ?(t)
  • When not blocked jobs are scheduled in a
    priority-driven, preemptive manner according to
    their assigned priorities.
  • Allocation Rule
  • Allocate when requested

53
Stack-based Priority Ceiling
  • Assume jobs never self suspend
  • After a job is released, when it begins to
    execute all the resources it needs are free
  • no job is ever blocked once its execution begins
  • when a job is preempted, all the resources needed
    by the preempting job are available
  • deadlock will not occur
  • Has the same worst-case performance as the basic
    priority ceiling protocol

54
Terminology for WFQ
  • Generalized Processor Sharing (GPS)
  • provides server an infinitesimally small time
    slice of length proportional to server size.
  • Not practical
  • Density of a sporadic job Ji
  • ei maximum execution time
  • ri release time
  • di deadline, density ei/(di-ri)
  • active in feasible interval (ri, di
  • Instantaneous utilization of a sporadic task
  • ui maxj(eij/pij)
  • independent, preemptable sporadic jobs are
    schedulable by EDF if total density lt 1

55
Fairness and Starvation
  • Fairness
  • Consider a system of n servers.
  • let wi(t1,t2) equal the processor time used by
    server Si (i.e. allocated processor time) in
    interval I (t1, t2 for t2 gt t1.
  • Normalized service wi(t1,t2)/ui fair if the
    normalized service of all servers differ by no
    more than a fairness threshold FRgt0.
  • Goal is to provide fair access to processor while
    permitting jobs to use an idle processor
  • Non-preemptive version used for network packet
    scheduling
  • Jobs are assigned a finish number that represents
    the round in which its deadline occurs (think of
    this as virtual time).

56
Weighted fair queuing preemptive
  • FN system finish number, Ub backlogged
    utilization
  • Scheduling
  • A server is eligible when it has budget and an
    assigned finish number
  • Priority assigned to eligible servers based on
    finish number Server with smallest finish time
    has highest priority
  • Consumption
  • Consume only when running
  • Initialization
  • I1 Idle system, set FN0, Ub0, t-1 0 ei,fni
    0 for all i.
  • I2 first job arrives to an Idle system for some
    server FQk set t-1 t, Ub uk, budget ek e
    and fnk e/uk
  • Updating current finish number and replenishment
  • R1 job arrives at an idle server FQi, then 1
    increment system FN FN (t-t-1)/Ub 2 set t-1
    t and increment Ub ui 3 update FQi ei
    e fni FN e/ui and place in ready queue
  • R2 FQi completes a job, remove it from the
    queue if still backlogged ei e fni
    e/ui else (idle) FN (t - t-1)/Ub, set t-1
    t decrement Ub - ui
Write a Comment
User Comments (0)
About PowerShow.com