Processes and Threads
A version of this page is also available for
4/8/2010
All applications that are based on Windows Mobile consist of a process and one or more threads.
- A process is a single instance of a running application.
- A thread is an independent portion of a process.
Processes
Processes enable users to open and work in several applications at the same time. For example, a user can edit a file in a text editor while another application is recalculating a spreadsheet.
As a preemptive multitasking OS, Windows Mobile supports multiple processes running simultaneously on the system.
There is no limit to the number of processes that can run on a Windows phone. The only limit is the amount of available system resources.
Threads
A thread is the basic unit to which the OS allocates processor time. Threads have the following characteristics:
- They enable an application to perform more than one task at a time, even though applications cannot run more than one thread at a time.
- They can run any part of the process code, including parts that are being run by another thread.
- Although one thread is designated as the primary thread for the process, a process can also create an unspecified number of additional threads.
- Available system resources limit the number of threads.
- Windows Mobile provides 256 priority levels that you can set for a thread. To assign priority levels, Windows Mobile uses the following functions:
- CeSetThreadPriority sets the priority for a specified thread.
- CeGetThreadPriority returns 0 (zero) as the highest priority and 255 as the lowest priority.
- If an OEM enforces a trusted environment, Windows Mobile can protect the top 248 priority levels from applications.
Because Windows Mobile supports preemptive multitasking, it creates the effect of a process simultaneously running multiple threads. When a process has more than one thread running, the OS rapidly switches from one thread to another so that the threads appear to run simultaneously.
See Also
Concepts
Scheduling
Processes
Threads
Fibers
Priority Levels
Priority Inversion
Controlling Timing with the Sleep Timer