Presentation is loading. Please wait.

Presentation is loading. Please wait.

 Wind River Systems, Inc. 1997 Chapter - 8 Memory.

Similar presentations


Presentation on theme: " Wind River Systems, Inc. 1997 Chapter - 8 Memory."— Presentation transcript:

1  Wind River Systems, Inc Chapter - 8 Memory

2 3-2 Memory Layout LOCAL_MEM_LOCAL_ADRS RAM_LOW-ADRS FREE_RAM_ADRS VxWorks SYSTEM MEMORY POOL sysMemTop( ) WDB_POOL_SIZE USER_RESERVED_MEM sysPhysMemTop( )

3 3-3 Target Server Memory Pool A pool of memory on the target reserved for use by the Tornado tools : Dynamic loading of object modules. Spawning task from WindSh or CrossWind. Creation of variables from WindSh. The initial size of the target server memory pool is configured by WDB_POOL_SIZE. The default is 1 / 16 of sysMemTop( ) - FREE_RAM_ADRS. The target server manages the pool, keeping overhead such as block lists on the host. Additional memory is silently allocated from the system memory pool, if needed.

4 3-4 System Memory Pool Initialized at system startup. Used for dynamic memory allocation in programs : malloc( ). Creating tasks (stack and TCB). Can modify USER_RESERVED_MEM to reserve memory for application-specific use. May need to modify sysPhysMemTop( ) (or just LOCAL_MEM_SIZE) when adding memory to your board. To add off board memory : void memAddToPool (pPool, poolSize) pPool must be the local address of the memory. VxWorks memory requests.

5 3-5 Allocating / Releasing Memory Uses first-fit algorithm. To dynamically allocate memory : void *malloc (nBytes) Returns a pointer to the newly allocated memory or NULL on error. Free memory is stored in a linked list. Some (small) overhead for each malloc( ). To release allocated memory : void free (ptr) Adjacent blocks are coalesced.

6 3-6 Debugging Options Default free( ) debugging : Default malloc( ) debugging : If request too large, log an error message. Check block for consistency. If corrupted: suspend task, log error message. Can change default debugging options with : void memOptionsSet (options) Options can be : + MEM_ALLOC_ERROR_LOG_FLAG - MEM_ALLOC_ERROR_SUSPEND_FLAG + MEM_BLOCK_CHECK + MEM_BLOCK_ERROR_LOG_FLAG + MEM_BLOCK_ERROR_SUSPEND_FLAG

7 3-7 Examining Memory Enter the memory partition ID in the Show box. Use the browser. Free List Mempart Ox Total bytes= Allocated blocks=86 bytes= Free blocks=7 bytes= Cummulative blocks=88 bytes= Free List 0 addr=0x3fd8f8 size= addr=0x4ef90 size=

8 3-8 Additional System Memory Management Routines void *calloc(nElems, size )Allocate zeroed memory for an array. void *realloc(ptr,newSize)Resize an allocated block. The block may be moved. int memFindMax( )Returns the size of the largest free block in system memory.

9 3-9 Fine Tuning For fast, deterministic allocation of fixed size buffers, use message queues instead of malloc( ). message queue ptr.. bufGet( ) bufReturn( ).. buffers

10 3-10 Generic Partition Manager VxWorks provides low level routines to create and manipulate alternate memory pools. High level routines like malloc( ) and free( ) call these lower level routines, specifying the system memory pool. Application may use alternate memory partitions to reduce fragmentation. Applications may use alternate memory partitions to manage memory with different properties.

11 3-11 Creating a memory Partition Returns a partition id (PART_ID) or NULL or error. The memory for this partition (pPool) may be taken from : PART_ID memPartCreate (pPool, size) pPoolPointer to memory for this partition sizeSize of memory partition in bytes. A separate memory board. A block allocated from the system memory partition. The top of the CPU board’s RAM.

12 3-12 Managing Memory Partitions System partition management routines call routines listed below, specifying the PART_ID as memSysPartId. GenericSystem Memory Pool memPartAlloc( )malloc( ) memPartFree( )free( ) memPartShow( )memShow( ) memPartAddToPool( )memAddToPool( ) memPartOptionsSet( )memOptionsSet( ) memPartRealloc( )realloc( ) memPartFindMax( )memFindMax( )

13 3-13 Example Creating a Memory Partition -->partId=memPartCreate(pMemory, ) new symbol “partId” added to symbl table. partId = 0x23ff318 : value = = 0x23ff328 = partId + 0x10 -->ptr=memPartAlloc(partId, 200) new symbol “ptr” added to symbl table. ptr = 0x23ff2ec : value = = 0x23e >show partId statusbytesblocksave blockmax block current free alloc cumulative alloc

14 3-14 Summary To configure the system memory pool : Standard C routines used for dynamic memory allocation. Modify sysPhysMemTop( ) Modify USER_RESERVED_RAM Modify memAddToPool( ) For fast, deterministic allocation of fixed size buffers, use message queues instead of malloc( ). Create separate memory partition for off-board memory, or to help reduce fragmentation.


Download ppt " Wind River Systems, Inc. 1997 Chapter - 8 Memory."

Similar presentations


Ads by Google