Main Page | Data Structures | File List | Data Fields | Globals

cctalk-svr-mem.c File Reference


Detailed Description

memory allocation manager for the cctalk server

This memory allocation manager will obtain blocks of memory from the system and return packets to the server. The blocks will be bigger than required by the server. The server will only request memory from the system as needed and pass out smaller blocks to the server as needed.

The whole point is that a system block is 4K but the only operation that needs memory is a cctalk operation these are queued here in the server. A cctalk operation is 536-bytes so seven of these at a time are requested from the system. This will hopefully reduce memory fragmentation of available free memory to Linux.

NOTE from man page on malloc & free: In case Linux is employed under circumstances where it would be less desirable to suddenly lose some randomly picked processes, and moreover the kernel version is sufficiently recent, one can switch off this over-committing behavior using a command like: # echo 2 > /proc/sys/vm/overcommit_memory

Author:
Rod Boyce
Date:
18/10/04

#include <stdlib.h>
#include <string.h>
#include "cctalk-channel-defs.h"
#include "cctalk-operations.h"
#include "cctalk-channel.h"
#include "cctalk-pkts.h"
#include "cctalk-pkt-utls.h"
#include "cctalk-debug.h"

Include dependency graph for cctalk-svr-mem.c:

Include dependency graph

Data Structures

struct  sCCTM_ALLOCATED_MEMORY
union  tuMALLOC_BLOCK

Typedefs

typedef sCCTM_ALLOCATED_MEMORY tsCCTM_ALLOCATED_MEMORY

Enumerations

enum  teCCTALK_MEMORY_CONSTANTS { eNUM_OPERATIONS_IN_BLOCK = 7, eSIZE_OF_MEMORY_CHUNK = 4096 }

Functions

void cctm_AllocateMoreMemory (void)
 Called when run out of cctalk operation structures.

void cctm_Initialise (void)
 Initialise the cctalk memory manager.

void cctm_Shutdown (void)
 close down the memory manager.

tsCCTALK_OPERATIONcctm_MallocOp (void)
 Get a packet from the free list and return it.

void cctm_FreeOp (tsCCTALK_OPERATION *pCctOp)
 Free a cctalk operation.


Variables

tsCCTALK_OPERATIONpsFreeCctOps
tsCCTM_ALLOCATED_MEMORY * psAllocatedMemory
int zlNumberFreeCctOps
int zlNumAllocatedCctOps

Enumeration Type Documentation

enum teCCTALK_MEMORY_CONSTANTS
 

Enumeration values:
eNUM_OPERATIONS_IN_BLOCK  This number represents the number of cctalk operations that fit inside a single 4K memory allocation
eSIZE_OF_MEMORY_CHUNK  Size of a memory allocation unit


Function Documentation

void cctm_AllocateMoreMemory void   )  [static]
 

Called when run out of cctalk operation structures.

This will make a system call to allocation more cctalk operation structures. Structures are allocated on a block basis.

Date:
26/10/04
Author:
Rod Boyce.

History

cctm_FreeOp tsCCTALK_OPERATION pCctOp  ) 
 

Free a cctalk operation.

Return a cctalk operation to the free list call when finished with a cctalk operation.

Date:
26/10/04
Author:
Rod Boyce
Parameters:
pCctOp - pointer to the cctalk operation structure to free.

History

cctm_Initialise void   ) 
 

Initialise the cctalk memory manager.

Set up the memory manager this is going to be a block manager it is not overly complicated but there are a few complications

Date:
26/10/04
Author:
Rod Boyce
Parameters:
\return 

History

Here is the call graph for this function:

cctm_MallocOp void   ) 
 

Get a packet from the free list and return it.

Called by the server to allocate a cctalk operation that can be used to store an cctalk operation. A cctalk structure is taken from the free list and returned to the calling process.

Date:
26/10/04
Author:
Rod Boyce
Returns:
pointer to a cctalk structure

History

Here is the call graph for this function:

cctm_Shutdown void   ) 
 

close down the memory manager.

Date:
26/10/04
Author:
Rod Boyce Called when closing down the system. All memory that is being used by the system is freed.

History


Generated on Thu Jan 20 16:13:06 2005 for Axis cctalk sub-system by doxygen 1.3.6