Win32 Thread scheduling

前端 未结 5 1631
逝去的感伤
逝去的感伤 2020-12-30 06:04

As I understand, windows thread scheduler does not discriminate beween threads belonging two different processes, provided all of them have the same base priority. My questi

5条回答
  •  南笙
    南笙 (楼主)
    2020-12-30 06:38

    Scheduling in Windows is at the thread granularity. The basic idea behind this approach is that processes don't run but only provide resources and a context in which their threads run. Coming back to your question, because scheduling decisions are made strictly on a thread basis, no consideration is given to what process the thread belongs to. In your example, if process A has 1 runnable thread and process B has 50 runnable threads, and all 51 threads are at the same priority, each thread would receive 1/51 of the CPU time—Windows wouldn't give 50 percent of the CPU to process A and 50 percent to process B. To understand the thread-scheduling algorithms, you must first understand the priority levels that Windows uses. You can refer here for quick reference.

    Try reading Windows Internals for in depth understanding.

提交回复
热议问题