首页 > 其他 > 详细

Context Switches msdn

时间:2017-11-24 17:43:38      阅读:337      评论:0      收藏:0      [点我收藏+]

Context Switches

 https://msdn.microsoft.com/en-us/library/ms682105(VS.85).aspx

The scheduler maintains a queue of executable threads for each priority level. These are known as ready threads. When a processor becomes available, the system performs a context switch. The steps in a context switch are:

  1. Save the context of the thread that just finished executing.
  2. Place the thread that just finished executing at the end of the queue for its priority.
  3. Find the highest priority queue that contains ready threads.
  4. Remove the thread at the head of the queue, load its context, and execute it.

The following classes of threads are not ready threads.

  • Threads created with the CREATE_SUSPENDED flag
  • Threads halted during execution with the SuspendThread or SwitchToThread function
  • Threads waiting for a synchronization object or input.

Until threads that are suspended or blocked become ready to run, the scheduler does not allocate any processor time to them, regardless of their priority.

The most common reasons for a context switch are:

  • The time slice has elapsed.
  • A thread with a higher priority has become ready to run.
  • A running thread needs to wait.

When a running thread needs to wait, it relinquishes the remainder of its time slice.

Context Switches msdn

原文:http://www.cnblogs.com/feng9exe/p/7891516.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!