Class Meeting #19: Review for Exam, Threads
Topics for Today
- Assignment #3: if you worked in a team
on the original gizmo controller assignment
you are required to choose a new partner for this one
- Review for midterm exam (see below)
- Review correct use of mutexes and conditions variables with threads,
and design of gizmo controller using threads (see further below)
Topics Covered on Midterm Examination
- No excuse for missing anything on the prior quizzes!
- No excuse either for missing anything on the prior midterms exams:
- Do not assume the exam this term will be so similar to these
two as they were to one another!
- See next slide for an independent list of topics
More Topics to Study for Midterm Examination
- Critical zone definition, theorem, and proof for preemptive fixed-priority
scheduling of independent periodic and sporadic tasks on one CPU
- EDF and Rate monotonic utilization bound theorems
- Response-time test for fixed-priority preemptive scheduling of
independent periodic ans sporadic tasks on one CPU
- Definition of priority inversion, why is it a problem,
and how to bound it using
mutexes with priority inheritance or non-preemption.
- Demand bound and load bound functions, and how to estimate
them experimentally via benchmark program (your last assignment)
An OO Thread-based Design for Gizmo Controller
- Sensor thread - periodically polls sensors, and maintains
estimated position of blade; adjusts period of solenoid thread if
necessary; may also wake up LED thread
- Solenoid thread - periodically pulses solenoid; sleeps
briefly between turning solenoid on and turning it off; may wake
up LED thread if that is not done by Sensor thread
- LED thread - periodically outputs new LED settings from
message buffer; may sleep during periods when LEDs need to stay
out
- Input thread (main) - reads test input from user, and updates
message buffer; may shut down other threads
Set priorities according to rate monotonic model
Main issue now becomes how to safely share state
Safe Sharing of Data between Threads
- Single writer solutions, using volatile atomic variables
- Protection with mutexes
See examples via links below for details on both.
Signaling Events between Threads
- Use condition variables
- Always use pthread_cond_wait in a loop with a state variable test
- Allow for spurious and multiple wake-ups
- Protect the state variable with a mutex
Notes and Examples of Thread Programming
Including correct usage of condition variables and mutexes
Things for You to Do
- Read Chapter 7 of the text
- Review chapter 1-6 and class notes, in preparation
for midterm exam on 02 November
- Work on redoing gizmo controller using threads
© 2006 T. P. Baker
($Id: wk10t.html,v 1.1 2008/08/25 11:18:48 baker Exp $) |