When you start a Windows CE-based application, the operating system automatically creates a process and a primary thread for that process. A process is a single instance of a running application and a thread is the basic unit of execution. Windows CE-based applications can incorporate multiple processes and each process can contain multiple threads.
Every process has at least one thread. You create additional threads by calling the CreateThread function. You call the ExitThread function to free up the resources used by a thread when it is no longer needed. Calling Exit Thread for an application's primary thread causes the application to terminate.
Note Unlike processes on Windows-based desktop platforms, a Windows CE process will terminate if its primary thread is terminated, even if there are other active threads in existence for the process.
When the Windows CE operating system initializes, it creates a single 4 GB virtual address space. It is divided into 33 slots, each 32 MB. The address space is shared by all processes. When a process initializes, Windows CE selects an open slot for the process in the system's address space. Slot zero is reserved for the currently running process. In addition to assigning a slot for each process, Windows CE creates a stack and a message queue for each thread in the process. Each stack has an initial size of at least 1 KB. Because the stack size is CPU-dependent; the system allocates 4 KB for each stack on some devices. The maximum number of threads is dependent upon the amount of available memory.
When a process initializes, the operating system stores in the slot assigned to the process all dynamic-link libraries (DLLs), the stack, the heap, the application code, and the data section for each process. DLLs are loaded at the top of the slot, followed by the stack, the heap, and the executable file (.exe). The bottom 64 KB is always left free.
For an overview of processes and threads, see Overview of the Windows CE Operating System. For a list of the functions that support manipulating processes and threads, see Lists of Functions and Interfaces.