NAME

intro ­ Introduction to Section 5: Memory Usage

DESCRIPTION

The amount of RAM required by each pSOSystem software component depends on the user's application. This section provides formulas for calculating these requirements based on application parameters. The following components are discussed:

NAME

pSOS+ - RAM requirements

DESCRIPTION

The pSOS+ kernel needs RAM for the following elements:

Data Area

The pSOS+ kernel uses the beginning of the user-defined memory Region 0 to build its data area. The size of this data area is calculated as the sum of the items in the table that follows. In the Size column of this table, the parameters that begin with kc and mc are entries in the pSOS+ Configuration Table and the Multiprocessor Configuration Table, respectively:

Usage Size (bytes, decimal)
System stack kc_sysstk
Task Control Blocks (TCBs) (kc_ntask + 2) x 348
Queue Control Blocks (QCBs) kc_nqueue x 76
Semaphore Control Blocks (SCBs) kc_nsema4 x 36
Message Buffers kc_nmsgbuf x 20
Timer Control Blocks (TMCBs) kc_ntimer x 48
Local Object Table (kc_nlocobj x 32) + 84
Global Object Table (Master Node) mc_nnode x ((mc_nglbobj x 32) + 84)
Global Object Table (Slave Node) (mc_nglbobj x 32) + 84
Agents mc_nagent x 56
IO Devices kc_nio x 32

If Region 0 is not large enough to contain the pSOS+ data area and the Region 0 header, a fatal error occurs during pSOS+ startup. To accommodate future expansion, it is recommended that the pSOS+ data area be padded with an extra 20% of space.

Task and System Stacks

Every task must have a stack. The memory for all stacks is allocated from Region 0. The size of a task's stack is defined by parameters passed in the t_create() system call. The following paragraphs describe issues that must be considered when sizing the task stack.

First, sizing this task requires a determination of the worst case, nested procedure stack usage.

Secondly, both pSOS+ kernel and interrupts are involved in sizing a task's stack. Any of the following can use a task's supervisor stack:

Since interrupt activities use the stack of the running task, every task's stack must be large enough to accommodate worst case interrupt usage. This usage must include the nesting of all possible interrupt levels. If an ISR makes a pSOS+ system call, pSOS+ usage of the stack must also be considered.

Region Header Memory Usage

When a region is created, some memory for its management is reserved at the beginning of the region memory. This memory space is the Region Header. The size of a Region Header is computed from the following formula:

80+ ((length-80/unit_size+6)) x 6 bytes, rounded up to the next even multiple of unit_size

where length and unit_size are parameters to the rn_create() call.

In addition to regions in general, this formula is also valid for Region 0 if length has the value of the pSOS+ Configuration Table entry kc_r0len minus the memory requirements of the pSOS+ Data Area. For example, if kc_r0len is 10 Kbytes and the pSOS+ Data Area is 3 Kbytes, then length should be 7 Kbytes in the preceding formula to calculate the Region 0 header size.

Segments obtained from a region have no additional memory overhead.

Partition Header Memory Usage

A Partition Header is the memory reserved in a partition for management of partition buffers. The following formula gives the amount of memory reserved for a Partition Header:

(52+(((length/bsiz)+7) / 8)) bytes, rounded up to the next even multiple of bsiz + (length modulo bsiz)

where length and bsiz are parameters passed to the pt_create() call, and / means integer division. Buffers allocated from a partition have no additional memory overhead.

TCB Extensions

At task creation, the pSOS+ kernel can add memory blocks called TCB extensions to the task's Task Control Block (TCB) for specific functions. Example functions of a TCB extension are to save FPU status and to support the needs of other components in the system.

If a task uses the FPU, 328 bytes are allocated for a TCB extension. The sizes of other TCB extensions appear in each component's Memory Usage section.

Variable Length Message Queue Storage

When a variable length message queue is created, the pSOS+ kernel allocates memory from Region 0 to store any messages that are pending at the queue during use. The following formula gives the amount of memory requested from Region 0:

maxnum x ((maxlen + 11) & -4)

where `&' is the bit-wise AND operator, and maxnum and maxlen are input parameters to q_vcreate(). No memory is allocated when either maxnum or maxlen is zero. The actual amount of memory allocated depends on the unit size for Region 0. The pSOS+ Configuration Table entry kc_rn0usize specifies the unit size for Region 0.

NAME

pHILE+ - RAM requirements

DESCRIPTION

The pHILE+ file system manager needs RAM for the following elements:

Data Area

Data area requirements for the pHILE+ file system manager depend on user-supplied entries in the pHILE+ Configuration Table. The size of the data area is the sum of the values generated by incorporating the relevant configuration table entries (each of which begins with fc) in the following formulas:

Usage Size in bytes
Static pHILE+ variables 964
Buffer headers fc_nbuf x 48
Cache buffers fc_nbuf x BUFFSIZE
Mounted volume table fc_nmount x 356
File control blocks (FCB) (fc_nfcb + fc_nmount) x 172
Directory name cache fc_ncfile x 36

Refer to pSOSystem System Concepts to determine the buffer size. Normally it is 2FC_LOGBSIZE.

Memory for the pHILE+ data area can be allocated from Region 0, or it can be allocated from a fixed location. The location depends on the pHILE+ Configuration Table entry fc_data.

Stack Requirements

The pHILE+ file system manager executes in supervisor mode and uses the caller's supervisor stack for temporary storage and automatic variables. pHILE+ worst case usage of the caller's stack is fewer than 1800 bytes. Therefore, a task that uses the pHILE+ file system manager should be created with at least that much stack space.

Task Extension Areas

With the pHILE+ file system manager in a system, the pSOS+ kernel allocates a pHILE+ TCB extension for each task at task creation. Memory for a TCB extension comes from Region 0, and the following formula gives its size:

140 +(32 x fc_ncfile)

where fc_ncfile is the entry in the pHILE+ Configuration Table that specifies the maximum number of open files allowed per task.

NAME

pREPC+ - RAM requirements

DESCRIPTION

The pREPC+ library needs RAM for the following elements:

Data Area

The pREPC+ library requires a fixed-size data area of 1704 bytes. Memory for the pREPC+ data area can be allocated from Region 0, or it can be allocated from a fixed location. The location depends on the pREPC+ Configuration Table entry lc_data.

Stack Requirements

The pREPC+ library uses the caller's stack for temporary storage and automatic variables. The pREPC+ library requires a maximum of 1 Kbyte of stack space. The 1 Kbyte specification assumes that no more than 10 floating point numbers are passed to a formatted I/O function. If more than 10 floating point numbers must be able to pass, the size of the calling task's stack must be increased to make room for the additional arguments.

TCB Extensions

With the pREPC+ library in a system, the pSOS+ kernel allocates a pREPC+ TCB extension for each task at task creation. Memory for a pREPC+ TCB extension comes from Region 0, and the following formula gives its size:

104 + (32 x (lc_numfiles + 3)) bytes

where lc_numfiles is the pREPC+ Configuration Table entry for the maximum number of simultaneously open files that a task can have (excluding stdin, stdout, and sterr).

NAME

pNA+ - RAM requirements

DESCRIPTION

pNA+ needs RAM for the following elements:

Data Area and Buffer Requirements

Data area requirements for the pNA+ data area depend on user-specified entries in the pNA+ and pSOS+ Configuration Tables and the initialization structure passed to pna_init(). The size of the data area is the sum of the values generated from the following formulas. The pNA+ Configuration Table entries begin with the letters nc, and kc_ntask is a pSOS+ Configuration Table entry.

Usage Size in Bytes
Static pNA+ variables 3372
Network Interface Table nc_nn1 x 110
Network Interface Table nc_nn1 x 112
Routing Table nc_nroute x 52
ARP Table nc_narp x 40
Host Table nc_hosts x 44
Socket Control Blocks nsockets x 152
Protocol Control Blocks nsockets x 82
Protocol Control Blocks nsockets x 84
Open Socket Tables (kc_ntask + 2) x 4 x (ndesc)

The sum of the following is the total memory needed for pNA+ buffer configuration:

Usage Size in Bytes
Message Blocks (mblks) nc_nmblks x 24
Data Block Table Number of different buffer sizes x 40
Nonzero-Sized Buffers pna_nbuffers x pna_bsize
Data Blocks for Nonzero-Sized Buffers pna_nbuffers x 24
Data Blocks for Zero-Sized Buffers pna_nbuffers x 32

Memory for the pNA+ data area can be allocated from Region 0, or it can be allocated from a fixed location. The location depends on the pNA+ Configuration Table entry nc_data.

Stack Requirements

pNA+ uses the caller's stack for temporary storage and automatic variables. The worst case stack usage by the pNA+ network manager is 2 Kbytes plus the worst case stack usage for network interface drivers. The interrupt stack size must be at least 2 Kbytes.

If the pROBE+ debugger is using the pNA+ network manager for communication purposes, the pROBE+ stack size must be increased by 2 Kbytes plus the worst-case stack usage for network interface drives.

TCB Extensions

With the pNA+ network manager in a system, the pSOS+ kernel allocates a pNA+ TCB extension for each task at task creation. Memory for a pNA+ TCB extension comes from Region 0, and its size is 24 bytes.

pNA+ uses STREAMS memory management internally for data transfer. Data is represented in the form of messages. Each message is a three- structure triplet: Message Block, Data Block, and Data Buffer.

Message Blocks

A packet in the pNA+ network manager consists of a linked list of mblks (message blocks). Each message block represents part of the packet. The message structure is defined as follows:

struct msgb {
   struct msgb *b_next;    /* Next message on the queue */
 struct msgb *b_prev;    /* Previous message on the queue */
     struct msgb *b_cont;    /* Next message block */
        unsigned char *b_rptr;  /* First unread byte in buffer */
       unsigned char *b_wptr;  /* First unwritten byte in buffer */
    struct datab *b_datap;  /* Pointer to data block */
     };
typedef struct msgb mblk_t;


b_next
contains a pointer to the next message in the queue.

b_prev
contains a pointer to the previous message in the queue.

b_cont
contains a pointer to the next message block of the message (packet).

b_rptr
is a pointer to the first unread byte in the data buffer referred by the message block

b_wptr
is a pointer to the first unwritten byte in the data buffer referred by the message block.

b_datap
is a pointer to the data block referred by the message block. The data block specifies the characteristics of the data buffer.

Data Blocks

A data block specifies the characteristics of the data buffer to which it refers. The structure is defined as follows:

struct datab {
  struct datab *db_freep; /* Internal Use */
      unsigned char *db_base; /* First byte of the buffer */
  unsigned char *db_lim;  /* Last byte+1 of buffer */
     unsigend char db_ref;   /* Number of refs to data buffer */
     unsigned char db_type;  /* Message type */
      unsigned char db_class; /* Used internally */
   };
typedef struct datab dblk_t;

db_freep
is used internally by the pNA+ network manager.

db_base
points to the first byte in the data buffer.

db_lim
points to the last byte + 1 of the data buffer.

db_ref
is the number of references to the data buffer.

db_type
is the type of data buffer.

db_class
is used internally by the pNA+ network manager.

Data Buffers

A data buffer is a contiguous block of memory used for storing packets/messages.

NAME

pRPC+ - RAM requirements

DESCRIPTION

pRPC+ requires:

NAME

pSE+ - RAM requirements

DESCRIPTION

pSE+ needs RAM for the following elements:

Data Area Requirements

The size of the data area is the sum of the values generated from the following formulas.

Usage Size in Bytes
Global pSE+ variables 2K

The sum of the following is the total memory needed for pSE+ buffer configuration:

Usage Size in Bytes
dblkinfo_size Number of different buffer classes x 32
fds_size (se_n_fds + se_n_links) x 76
queues_size se_n_queues x 60
mblks_size se_n_mblks x 24
dblks_size Total number of different buffers x 24
datasize Sum of different buffers x buffer size
bcinfos_size se_n_bufcalls x 24
tmoinfos_size se_n_timeouts x24
pollinfos_size se_n_fds x 12
inkblks_size

se_n_links x16

Memory for the pSE+ data area can be allocated from Region 0, or it can be allocated from a fixed location. The location depends on the pSE+ Configuration Table entry se_data_area.

Stack Requirements

pSE+ uses caller's stack for temporary storage and automatic variables. It requires 2K stack usage.

TCB Extensions

The pSOS+ kernel allocates a use+ TCB extension for each task at task creation. Memory for a pSE+ TCB extension comes from Region 0, and its size is 44 bytes.

NAME

pSKT+ - RAM requirements

DESCRIPTION

pSKT+ needs RAM for the following elements:

Data Area Requirements

pSKT+ needs memory for global variables, subcomponent data area and task specific variables. Memory is also needed for variables in SOMOD library.

Usage Size in Bytes
Global pSKT+ variables) 4
Subcomponent data area 24
Task specific variables 48 per task
SOMOD library variables 656

Memory for subcomponent data area and task specific variables come from Region 0. Memory for global pSKT+ variables comes from Region 0 and memory for SOMOD library variables is allocated at link time.

Stack Requirements+

pSKT+ uses caller's stack for temporary storage and automatic variables. It requires 2K stack usage.

TCB Extensions

The pSOS+ kernel allocates a pSKT+ TCB extension for each task at task creation. Memory for a pSKT+ TCB extension comes from Region 0, and its size is 24 bytes.

NAME

pTLI+ - RAM requirements

DESCRIPTION

pTLI+ needs RAM for the following elements:

Data Area Requirements

pTLI+ needs memory for global variables, subcomponent data area and task specific variables. Memory is also needed for variables in TIMOD and TIRW library.

Usage Size in Bytes
Global variables) 204
Subcomponent data area 12
Task specific variables 78 per task
TIMOD library variables 136
TIRW library variables 152

Memory for subcomponent data area and task specific variables come from Region 0. Memory for library variables also comes from Region 0.

Stack Requirements+

pTLI+ uses caller's stack for temporary storage and automatic variables. It requires 2K stack usage.

TCB Extensions

The pSOS+ kernel allocates a pTLI+ TCB extension for each task at task creation. Memory for a pTLI+ TCB extension comes from Region 0, and its size is 12 bytes.





psos_support@isi.com

Copyright © 1996, Integrated Systems, Inc. All rights reserved.