Delta Lists and Clock Processing - PowerPoint PPT Presentation

1 / 18
About This Presentation
Title:

Delta Lists and Clock Processing

Description:

Each clock tick must only decrement the head key to decrease the wait time ... of tick deferred ... subtracts the accumulated ticks from the delay of ... – PowerPoint PPT presentation

Number of Views:30
Avg rating:3.0/5.0
Slides: 19
Provided by: scie203
Category:

less

Transcript and Presenter's Notes

Title: Delta Lists and Clock Processing


1
Delta Lists and Clock Processing

2
Real Time Clock Management
  • A Real-Time clock generates clock interrupts at a
    (generally) fixed rate, defined by the computer
    architecture
  • The CPU must handle these interrupts in a timely
    manner to avoid both missing events and
    maintaining reasonable efficiency

3
Uses of a Real-Time Clock
  • Preemption
  • XINU executes resched() after a certain number of
    clock interrupts have occurred
  • Wake-Up Operations
  • Processes can be placed in a sleeping state,
    waiting a specified number of clock ticks before
    resuming operation

4
Delta List Processing
  • An efficient structure for storing sleeping
    processes is the Delta List
  • Delta lists are ordered by increasing time
  • Each list node key indicates the number of ticks
    after the previous event the event must wait
  • Each clock tick must only decrement the head key
    to decrease the wait time of all nodes

5
Insertd() - Insert Into Delta List
  • See Page 153 for source
  • Moves down the list decrementing key, the
    original number of ticks to wait, until the
    number of ticks left is smaller than the next
    node.
  • A new node is inserted for the remaining wait
    (key), and the next nodes delta is decreased by
    the value of key to maintain proper delta
    consistency

6
Other Real-Time Clock Optimizations
  • Global variables (used in clkint.c, pg. 158)
  • slnempt True if sleep queue is not empty
  • sltop Pointer to the top of the sleep queue

7
Putting a process to sleep
  • Two System Calls
  • a) sleept(n)
  • b) sleep(n)
  • (see pg. 154)

8
sleept(n) System Call sleept(n) delays the
calling process n ticks. It does so by
  • inserting the process into delta list
  • putting the process into PRSLEEP state
  • calling resched( )
  • (see pg. 155)

9
Sleep(n)
  • System Call Sleep(n) uses sleept(n) repeatedly to
    schedule shorter delay time until the delay time
    n seconds has elapsed. (see pg. 156)
  • Note Its argument specifies a delay measured in
    seconds rather than ticks.

10
Deferred Clock Process
  • To accumulate clock ticks without initiating
    events.
  • Motivation
  • The OS keeps interrupt disabled while it switches
    context.
  • Disabling interrupts poses no problem when input
    comes from a keyboard, because humans type slowly
    compared to the speed at which computer consumes
    data.

11
Deferred Clock Process (Contd.)
  • Problem
  • For some computer-to-computer communication
    data is sent and received at a high speed. If a
    context switch happens while receiving a large
    block of characters for example, some of the
    characters may be lost.

12
Deferred Clock Process (Contd.)
  • Solution
  • The I/O system needs to prohibit context switches
    for short period of time (deferred clock mode),
    even though interrupts remain enabled.
  • Ideally, the system should be able to make up
    for the lost time when context switching is
    reenabled again.

13
Deferred Clock Process (Contd.)
  • Solution (contd.)
  • Deferred clock processing consists of postponing,
    but not ignoring, context switches.
  • During a deferred clock period, context switching
    is suspended by deferring clock interrupts.
  • (see pg. 158)

14
Clock Interrupt Processing
  • Clock interrupt service routine clkint
  • updates the time-of-day (tod)
  • check(defclk)
  • true? update clkdiff
  • false? i) wakeup sleeping process

  • ii) update preemption counter

15
Procedure for changing to and from Deferred Mode
  • A process can place the clock in deferred mode
    by calling stopclk( ) and can return to real-time
    mode by calling strclk( ).
  • stopclk() counts deferred requests by
    incrementing defclk.
  • strclk() counts restart requests by decrementing
    defclk.

16
Procedure for changing to and from Deferred Mode
(contd.)
  • clkdiff number of tick deferred
  • As long as defclk remains positive, the interrupt
    handler counts clock ticks in clkdiff without
    processing them.

17
Procedure for changing to and from Deferred Mode
(contd.)
  • strclk() makes up for lost time when defclk
    reaches zero again, by catching up on all events
    that should have occurred while the clock
    remained deferred. To do so, strclk( )
  • updates the preemption counter
  • subtracts the accumulated ticks from the delay of
    sleeping processes
  • wakes up the processes whose sleep times have
    elapsed.

18
Awakening Sleeping Processes
  • Wakeup
  • makes ready all processes whose delay time has
    elapsed
  • removes process from clockq
  • resets sltop and slnempty to reflect the new
    queue status
  • calls resched( )
Write a Comment
User Comments (0)
About PowerShow.com