Memory Architecture (Windows CE 5.0)
In any Microsoft® Windows® CE–based device, ROM stores the entire operating system (OS), as well as the applications that come with the OS design.
If a module is not compressed, the OS executes the ROM-based modules in place. If the OS compresses a ROM-based module, it decompresses the module and pages it into RAM. The OS loads all read/write data into RAM. The OEM controls the option to enable compression in ROM.
When the OS executes programs directly from ROM, it saves program RAM and reduces the time needed to start an application, because the OS does not have to copy the program into RAM before launching it.
For programs contained in the object store or on a flash memory storage card, the OS does not execute these in place if the programs are not in ROM. Instead, the OS pages these programs into the RAM and then executes them.
Depending on the OEM and the driver options on a specific Windows CE–based device, the program module can be paged on demand. The OS can bring in one page at a time or load the entire module into RAM at once.
The RAM on a Windows CE–based device is divided into two areas: the object store and the program memory.
- The object store resembles a permanent, virtual RAM disk. Data in the object store is retained when you suspend or perform a soft reset operation on the system. Devices typically have a backup power supply for the RAM to preserve data if the main power supply is interrupted temporarily. When operation resumes, the system looks for a previously created object store in RAM and uses it, if one is found. Devices that do not have battery-backed RAM can use the hive-based registry to preserve data during multiple boot processes.
- The program memory consists of the remaining RAM. Program memory works like the RAM in personal computers — it stores the heaps and stacks for the applications that are running.
The maximum size for the RAM file system is 256 MB, with a maximum size of 32 MB for a single file. However, a database-volume file has a 16-MB limit. The maximum number of objects in the object store is 4,000,000.
Under low-memory conditions on some Windows CE–based devices, the OS might prompt the user for permission to take some object store RAM for use as program RAM to meet the RAM requirements of an application.
When Windows CE OS starts, it creates a single 4-gigabyte (GB) virtual address space. The address space is divided into 33 slots, and each slot is 32 megabytes (MB). All the processes share the address space. When a process starts, Windows CE selects an open slot for the process in the address space of the system. Slot zero is reserved for the currently running process.
Additionally, Windows CE creates a stack for the thread and a heap for the process. Each stack has an initial size of at least 1 kilobyte (KB) or 4 KB, which is committed on demand.
The amount of stack space that is reserved by the system, on a per-process basis, is specified in the /STACK option for the linker.
Because the stack size is CPU-dependent, the system on some devices allocates 4 KB for each stack.
The maximum number of threads is dependent on the amount of available memory. You can allocate additional memory, outside of the 32 MB that is assigned to each slot, by using memory-mapped files or by calling the VirtualAlloc function.
The following illustration shows how memory is allocated in the Windows CE address space.
When a process initializes, the OS maps the following DLLs and memory components:
- Some execute-in-place (XIP) dynamic-link libraries (DLLs)
- Some read/write sections of other XIP DLLs
- All non-XIP DLLs
- Stack
- Heap
- Data section for each process in the slot assigned to the process
DLLs and ROM DLL read/write sections are loaded at the top of the slot. DLLs are controlled by the loader, which loads all the DLLs at the same address for each process. The stack, the heap, and the executable (.exe) file are created and mapped from the bottom up. The bottom 64 KB of memory always remains free.
See Also
Virtual Memory | Heaps | Stack | Static Data Blocks | Static Data Blocks | Memory-mapped Files | Kernel Overview
Send Feedback on this topic to the authors