The Windows Scheduler

Loading...

Flash Player 9 (or above) is needed to view presentations.
We have detected that you do not have it on your computer. To install it, go here.

0 comments

Post a comment

    Post a comment
    Embed Video
    Edit your comment Cancel

    1 Favorite

    The Windows Scheduler - Presentation Transcript

    1. The Windows Scheduler Peter Shirley-Quirk
    2. The Windows Scheduler
      • In this presentation we will look at:
        • What the scheduler is
        • How it works
        • Tips for developers
    3. What is a scheduler?
      • A scheduler shares out the computer system’s processing resource fairly between all the processes it has to run
      • Types of scheduler
        • Long-term decides whether the system can run any additional jobs/processes
        • Mid-term used to swap out a process
        • Short-term decides which thread is to be executed
    4. How does Windows Scheduler work?
      • Scheduling algorithm
        • Managing a queue of threads that are ready to execute
        • Performing context switches and allocating time slices to respond to interrupts that affect which threads are able to run
        • Ensuring that threads get a chance to run
    5. When is a thread Ready to run? Figure 3-19, Inside Microsoft Windows 2000, Third Edition by David A. Solomon and Mark E. Russinovich
    6. Context switching (1)
      • Context switching happens:
        • At the end of a time slice
        • When a higher priority thread becomes ready e.g. garbage collection thread starts
        • When the currently running thread goes into a wait state
      • To run a thread the processor needs the full context
        • registers
        • stack (user and kernel)
        • environment
    7. Context switching (2)
      • To switch context the scheduler:
        • Saves the context for the executing thread
        • Places that thread at the end of the queue for its priority
        • Finds the highest priority queue that contains ready threads
        • Removes the thread at the head of the queue, loads its context, and executes it
    8. Process Priority Classes The Process Priority Class is under the designer’s control Can be read or set using System.Diagnostics.Process.PriorityClass AboveNormal Time-critical tasks that must be executed immediately e.g. the Task List dialog High BelowNormal E.g. multimedia applications RealTime E.g. screen saver, indexer etc. Idle No special scheduling needs. Normal
    9. Where does the priority come from?
      • The thread’s base priority is based on several factors
        • Process Priority Class
        • Thread Priority Level
        • Foreground / background
      • These combine to give the Thread’s Base Priority
      • The dynamic priority can be boosted by the scheduler
    10. When does the scheduler boost the priority?
      • Avoiding starvation
        • To prevent a high priority task from completely blocking a lower priority task the latter will be given a priority boost
      • Avoiding choking
        • CPU bound vs. IO bound – burst characteristics
        • A CPU bound thread can choke resources from an IO bound thread – perceived as poor responsiveness from mouse or keyboard
    11. Resolving priority inversion
      • Thread A, a low-priority thread, is executing code in a critical section (lock).
      • Thread B, the high-priority thread, begins waiting for a shared resource (e.g. the lock) from thread A.
      • Thread C has medium priority. Thread C receives all the processor time
      • Scheduler boosts priority of A so that it can exit the lock
      A B C Wait Ready Time Priority A
    12. What if there’s more than one processor?
      • The system uses a SMP model to schedule threads on multiple processors
        • Any thread can be assigned to any processor
        • The system schedules threads to run concurrently
        • You can influence the scheduler
          • Thread Affinity
          • Thread Ideal Processor
    13. Multi-Processor Architecture
      • Hyperthreading
        • 2 virtual processors but sharing some processor resources – consider using thread affinity
      • Intel Dual-core
        • Sharing onboard cache – thread affinity
      • AMD dual core
        • Treat as independent processors
      • The future: 4-way, 8-way
        • Design for parallel processing
    14. Some final thoughts
      • Designing for concurrency
        • Take advantage of multiple processors
        • Aim to blend CPU and IO work
      • Know your synchronization mechanisms
        • Design to avoid deadlock
        • Keep locks private and short
      • Be aware of Garbage Collection in .NET
        • Usually quick, occasionally quite slow
    15. More information
      • http://msdnwiki.microsoft.com
        • Managing Processes Sample 
        • System.Diagnostics namespace 
          • Process
          • ProcessThread
        • System.Threading namespace 
          • Thread

    + PeterSQPeterSQ, 2 years ago

    custom

    891 views, 1 favs, 0 embeds more stats

    An introduction to the Windows Scheduling algorithm more

    More info about this document

    © All Rights Reserved

    Go to text version

    • Total Views 891
      • 891 on SlideShare
      • 0 from embeds
    • Comments 0
    • Favorites 1
    • Downloads 0
    Most viewed embeds

    more

    All embeds

    less

    Flagged as inappropriate Flag as inappropriate
    Flag as inappropriate

    Select your reason for flagging this presentation as inappropriate. If needed, use the feedback form to let us know more details.

    Cancel
    File a copyright complaint
    Having problems? Go to our helpdesk?

    Categories