Intermec ck1 Reference Guide
Appendix A —
µClinux System
320
CK1 SDK Programmer’s Reference Manual
Memory allocation (malloc) is normally implemented at the low level
using the brk system call. Under the Unix environment, each created
process owns a specific memory region called a heap. This is used for
processing dynamic memory requests. The size of the memory region can
be increased or decreased directly by the brk() system call. Under
using the brk system call. Under the Unix environment, each created
process owns a specific memory region called a heap. This is used for
processing dynamic memory requests. The size of the memory region can
be increased or decreased directly by the brk() system call. Under
µClinux,
this system call cannot increase the memory region unless it goes trough
some changes.
some changes.
The process is allowed to allocate memory from the global pool of free
memory. The simplest memory allocation method under
memory. The simplest memory allocation method under
µClinux is
mmap() and munmap() to return the memory to the memory pool. The
choice of different methods for memory allocation depends also upon the
libc version. Both
choice of different methods for memory allocation depends also upon the
libc version. Both
µC-libc and µClibc support a simple allocator (malloc-
simple), which uses the mmap or munmap and lets the kernel actually
handle the allocation. The problem with this call is that the based
allocation is about 56 bytes, which can cause small memory requests to
crow quite high. The main problem lies in the fact that efficient and fast
memory allocation generally also adds code size to small applications.
handle the allocation. The problem with this call is that the based
allocation is about 56 bytes, which can cause small memory requests to
crow quite high. The main problem lies in the fact that efficient and fast
memory allocation generally also adds code size to small applications.
Memory Management
The virtual memory system provides a layer between the applications
memory request and the MMU. The main advantage of this system is that
the memory that the application refers to is separated from the physical
memory and that it provides a higher level memory protection. The virtual
memory request is allocated with cooperation from the MMU and the
kernel. The MMU provides a level of protection for applications that run
on the platform. Working without the MMU means that all of the
program memory is literally mapped against the physical memory. This is
called a flat memory architecture. An invalid memory pointer in your
application may trigger an address error that can completely freeze or
corrupt an MMU-less processor. The code implemented to an MMU-less
platform has to be working properly, which of course means thorough
testing.
memory request and the MMU. The main advantage of this system is that
the memory that the application refers to is separated from the physical
memory and that it provides a higher level memory protection. The virtual
memory request is allocated with cooperation from the MMU and the
kernel. The MMU provides a level of protection for applications that run
on the platform. Working without the MMU means that all of the
program memory is literally mapped against the physical memory. This is
called a flat memory architecture. An invalid memory pointer in your
application may trigger an address error that can completely freeze or
corrupt an MMU-less processor. The code implemented to an MMU-less
platform has to be working properly, which of course means thorough
testing.
Dynamic memory allocation in a flat memory model can also cause
fragmentation that also can starve the system. In an ideal case, the physical
memory is used as continuous memory areas and the allocation should fail
only when the number of free page frame is too small. Although the
memory would be large enough, there might not be a continuous piece of
memory available. This is also a problem in an operating system with
virtual memory. One way to overcome this is to request memory allocation
through the pre-allocated buffer pool.
fragmentation that also can starve the system. In an ideal case, the physical
memory is used as continuous memory areas and the allocation should fail
only when the number of free page frame is too small. Although the
memory would be large enough, there might not be a continuous piece of
memory available. This is also a problem in an operating system with
virtual memory. One way to overcome this is to request memory allocation
through the pre-allocated buffer pool.
Linux and other Unix like operating systems usually provide a method
called swapping. Here the kernel uses a part of the disk as an extension of
RAM in order for the process to run by the illusion that they have all the
physical memory available although some of their pages are stored away
and retrieved again when needed. In
called swapping. Here the kernel uses a part of the disk as an extension of
RAM in order for the process to run by the illusion that they have all the
physical memory available although some of their pages are stored away
and retrieved again when needed. In
µClinux this method is not possible