Process Structures Creating a Process Thread Structures Creating a Thread Scheduling Jobs
Open the image to be executed Create the Windows executive process object
1. 2.
a) Set up executive process block b) Create initial process address space
Create kernel process block d) Finish setup of process address space e) Set up the process environment block f) Finish setup of executive process block c)
3.
Create initial thread and its stack and context
4.
5. 6.
Notify the Windows subsystem about the new process Start execution of initial thread Perform process initialization in the context of the new process
1.
2. 3. 4.
5.
Create a user-mode stack in the process’s address space Initialize the thread’s hardware context Create the executive thread object in the suspended state Notify the Windows subsystem about the new thread (so it can do some setup work) Return thread handle and thread ID to caller
Scheduling is done at the thread level Time quanta (time slices) Dynamic or “boostable” Controllable by the user Stored in “thirds” for partial quantum usage
Priorities
32 levels, divided into two categories ▪ 16 “real-time” levels (16–31) ▪ 15 variable (dynamic) levels (1–15) ▪ 1 system level (0), reserved for the zero page thread
One queue per priority level Boostable also
Windows can boost a thread’s priority in these cases: On completion of I/O operations After waiting for executive events or semaphores After threads in a foreground process complete a
wait operation When GUI threads wake up because of windowing activity When a thread that’s ready to run hasn’t been running for some time (CPU starvation)
A job object is “a nameable, securable, shareable kernel object that allows control of one or more processes as a group.” Allows for management of groups of processes as a unit A process can be a member of only one job Holds basic accounting information for all processes in the job, whether terminated or running
Jobs allow for setting limits on processes:
Maximum number of active processes in the job Job-wide user-mode CPU time limit Per-process user-mode CPU time limit Job scheduling class—set the quantum length for processes in the job Job processor affinity Job process priority class Default working set minimum and maximum Process and job committed virtual memory limit
Debugging Tools for Windows http://www.microsoft.com/whdc/devtools/debugging/ Windows Debugger
Windows Sysinternals http://www.sysinternals.com/ Lots of wonderful utilities: ▪ Process Explorer ▪ Live Kernel Debugger ▪ Lots of other goodies
The Windows API Reference at MSDN Library http://msdn.microsoft.com/en-
us/library/aa383749(VS.85).aspx Kernel function reference
Microsoft Windows Internals Especially chapter 6 Fifth edition coming in January 2009 ▪ Windows Vista ▪ Windows Server 2008
“Mark’s Blog”: http://blogs.technet.com/markrussinovich/ Don’t forget Google