Applying kernel timers - PowerPoint PPT Presentation

About This Presentation
Title:

Applying kernel timers

Description:

Applying kernel timers. Could we prevent a device-driver from consuming an ... This proposed scheme is like a throttle' What does timer-function do? ... – PowerPoint PPT presentation

Number of Views:62
Avg rating:3.0/5.0
Slides: 9
Provided by: ProfessorA2
Learn more at: https://www.cs.usfca.edu
Category:

less

Transcript and Presenter's Notes

Title: Applying kernel timers


1
Applying kernel timers
  • Could we prevent a device-driver from consuming
    an excessive amount of processor time?

2
Degraded system performance
  • Recall our Interrupt Activity Monitor demo
  • Its posted on class website (activity.cpp)
  • Repeatedly called a drivers read function
  • But used over 99-percent of the cpu time!
  • (We discovered that fact with top utility)
  • Name of the driver module was activity.c

3
Kernel software timers
  • We also learned how to use kernel timers
  • An easy-to-use programming interface
  • Data-object struct timer_list
  • And four kernel functions
  • init_timer()
  • add_timer()
  • mod_timer()
  • del_timer()

4
Sleep/Wakeup
  • Earlier we encountered Linux task states
  • A Linux task can easily be put to sleep
  • While asleep a task doesnt use cpu time
  • A timer-function could wake up our task

5
How it might work
  • Our device-drivers read() functon
  • Before reading any new data, check to see
  • how long its been since we last did a read
  • If we discover we read data quite recently, then
    we could set-a-timer and go-to-sleep
  • When awakened well return the new data
  • This proposed scheme is like a throttle

6
What does timer-function do?
  • Our driver needs a ready flag 0 or 1
  • The read() function sets ready FALSE
  • The timer-function sets ready TRUE
  • read() will sleep until ready TRUE
  • And timer-function will wake up driver

7
Lets try it!
  • Some demo-code is on our class website
  • Device-driver module tsc.c
  • Application program watchtsc.cpp
  • First Try out the demo (use top utility)
  • Next Modify the driver-module
  • Add a wait-queue
  • Add a kernel timer
  • Finally Use top again to check cpu usage

8
TimeStamp Counter
  • Pentium cpu has a built-in TSC register
  • Incremented once every cpu clock-cycle
  • Register is 64-bits wide (8-bytes)
  • It wont overflow for at least a decade!
  • Accessed using special instruction rdtsc
  • EAXleast significant 32-bits of TSC
  • EDXmost signigicant 32-bits of TSC
Write a Comment
User Comments (0)
About PowerShow.com