AN2345 Freescale Semiconductor / Motorola, AN2345 Datasheet - Page 3

no-image

AN2345

Manufacturer Part Number
AN2345
Description
Real-Time Memory Manager for StarCore DSPs
Manufacturer
Freescale Semiconductor / Motorola
Datasheet
1.3 Reentrancy
VSMM routines execute in a known and deterministic way; that is, each VSMM routine has a known and
bounded response time. Details on this response time can be found within the interface control document
(ICD) [6] of each VSMM module.
In the VSMM heap schema, freeing a memory block merely points the current block to the memory block
to which the global free list pointer is pointing. Then the global free list pointer is updated to point to the
starting address of the freed memory block, a very efficient and deterministic process (see Figure 3).
Notice that the free space is not contiguous. Rather, each free block points to the next free block within
the heap, and there are no unreachable blocks.
Most embedded systems use interrupts, and many support multitasking or multi-threaded operations. In
such applications, the program control flow can change contexts at any time. When an interrupt occurs,
the current operation is put on hold, and another operation starts. If these operations share variables, you
must ensure that one routine does not corrupt the data of another. By carefully controlling how data is
shared, you create reentrant functions that allow multiple concurrent invocations but do not interfere with
each other. Reentrancy is a term to describe a module in which multiple processes can share the same
copy in memory. A reentrant module ensures that no instructions modify the contents of variable values
outside its context. A reentrant module must satisfy the following reentrancy rules:
1. An atomic operation is one that cannot be interrupted. Use all shared variables in an atomic way, unless
2. Do not call non-reentrant functions.
3. Do not use the hardware in a non-atomic way.
each is allocated to a statically declared specific instance of the function.
An instance is a path through the code. There is no reason a single function cannot be called from many
places. In a multitasking environment, it is possible that several copies of the function may execute
concurrently. The use of automatic variables—that is, local variables that are statically declared within
a module—ensures reentrancy since each call to this module has its own copy of these variables
created on the stack. Another option is to allocate memory dynamically so that each iteration uses a
unique data area.
Calling a non-reentrant routine effectively makes the routine that performed the call non-reentrant.
Hardware looks a lot like a variable. If more than a single I/O or hardware operation is required to
handle a device, reentrancy problems can result. To prevent reentrancy issues on shared hardware,
FreeList Pointer
1
2
1
Free space
Marked space
Freescale Semiconductor, Inc.
Figure 3. Heap with Fixed-Sized Memory Blocks
2
For More Information On This Product,
2
Go to: www.freescale.com
1
1
2
1
1
1
Memory Manager Limitations
2
2
2
2
3

Related parts for AN2345