Using Threads
The CreateThread function creates a Real-time thread. The initial or main thread of a process has a 48 KB stack. This size will not grow. It can only be altered by editing the Stack Reserve and Commit Size variables in the Visual Studio System Linker process properties.
You can specify the stack size of subsequently created threads of a process using CreateThread. The returned handle and thread ID are valid only in the CreateThread caller's environment.
Timer and Interrupt Objects
Timer and interrupt objects derive from threads; therefore, the handles for these objects are valid only in their own Process environment. Similarly, these objects can be manipulated only by processes in their own environment, and only by the threads in the process they were created in.
Process Environment
A thread is the unit of execution in the Process environment. A ready-to-run thread is scheduled based upon its priority. A thread runs until it gives up the CPU.
A thread gives up the CPU when it:
- Waits for a synchronization object
- Lowers its own priority or raises another thread's priority
- Suspends itself
- Returns from the timer or interrupt handler routines (applicable to timer and interrupt threads)
- Calls Sleep with an argument of 0
- Receives a notification that a time quantum is expired
- Is interrupted by a higher priority
Related topics: