Hart.gif (5380 bytes)Win32 System Programming

Return to Addison-Wesley Home Page  


Return to Top Page

Notes on Windows CE


A large sample program is in the samples file.

MicrosoftÆ WindowsÆ CE is a platform designed for embedded systems, communication devices, entertainment systems, palmtop PCs, and a wide range of resource-restricted devices. The important point for us is that it provides a subset of the Win32 API, so, with some care, Win32 programs can operate under Windows CE. Furthermore, a person wanting to learn Windows CE system programming can use the material in this book, with suitable restrictions.

Note: "CE" probably denotes "Consumer Electronics" the same way the "NT" probably denotes "New Technology." Some people, however, note that if you decrease each letter in "WNT" you get "VMS" the venerable operating system from Digital Equipment Corporation.

These notes, which I'll augment from time to time (please feel free to send me any relevant information) will describe the significant Windows CE limitations and differences with respect to Win32. In addition, programming examples will illustrate various techniques that are relevant to Windows CE.

The first example shows how to implement semaphores using mutexes and an event. Windows CE provides these two objects, but it does not provide semaphores. This example will also be interesting to Windows 95/98 and NT programmers as it illustrates a number of synchronization features and behaviors that may not be obvious.

For more information on Windows CE and to obtain the development kit (you need to be using Visual C++ Version 5.0 or greater), see the Microsoft page at

http://www.microsoft.com/windowsce/developer/

Here are some initial notes regarding Windows CE relative to Win32.

I/O

  • No asynch I/O
  • There is a lot more to be added.

Security

No security, so the security attributes should be null in all calls. Does this mean that handles cannot be inherited? Yes, it does.

Processes and Threads

  • There is a limit of 32 processes.
  • There is only a single address space, but processes can't interfere.
  • There can be as many threads as there is room for.
  • TLS is supported.

CreateProcess

  • The name of the module being executed cannot be passed in as a command line argument.
  • Windows CE does not support handle inheritance by the newly created process. Therefore, you cannot duplicate a handle into another process or set a child process's standard handles.
  • Windows CE does not support security attributes for processes and their primary threads.
  • A search path to the executable module cannot be specified. Windows CE will search the following path for the module:

The root directory of the PCMCIA RAM expansion card, if one exists (see the Microsoft home page for information)

The windows directory; (\Windows)

The root directory; (\)

  • Priority classes for processes are not supported under Windows CE.
  • Most of the parameters have to be NULL - check the documentation.

TerminateProcess

  • Windows CE does not support exit codes for processes.
  • Processes cannot terminate themselves.

CreateThread

Each process has a primary thread that is created automatically when the process is created. Additional threads can be created by calling the CreateThread function. The ExitThread function should be called to free up the resources used by the thread when it is no longer needed. Calling ExitThread for an application's primary thread will cause the application to terminate (this use of the primary thread appears to differ from normal Win32 - check). Windows CE does not support the TerminateThread function used for one thread to kill another thread (this is the opposite from processes).

Synchronization

  • No semaphores. See the sample code below for an implementation using events and mutexes. It is not as easy as you might think. The library contains Create, Release, Wait (single only), and Close functions that operate on a handle-like structure.
  • Critical Sections: There does not appear to be a TryCriticalSection. Check.
  • Interlocked functions are provided.
  • Event Objects cannot be named; documentation implies that mutexes can be named

Windows CE Semaphore - Sample Code

  1. The implementation of the Create, Wait, Release, and Close functions
  2. The header file
  3. The test program

See the sample code file.