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:
The pSOS+ kernel needs RAM for the following elements:
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:
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.
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.
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.
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.
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.
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:
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.
The pHILE+ file system manager needs RAM for the following elements:
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:
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.
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.
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:
where fc_ncfile is the entry in the pHILE+ Configuration Table that specifies the maximum number of open files allowed per task.
The pREPC+ library needs RAM for the following elements:
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.
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.
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).
pNA+ needs RAM for the following elements:
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.
The sum of the following is the total memory needed for pNA+ buffer configuration:
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.
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.
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.
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;
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;
A data buffer is a contiguous block of memory used for storing packets/messages.
pRPC+ requires:
pSE+ needs RAM for the following elements:
The size of the data area is the sum of the values generated from the following formulas.
The sum of the following is the total memory needed for pSE+ buffer configuration:
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.
pSE+ uses caller's stack for temporary storage and automatic variables. It requires 2K stack usage.
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.
pSKT+ needs RAM for the following elements:
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.
pSKT+ uses caller's stack for temporary storage and automatic variables. It requires 2K stack usage.
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.
pTLI+ needs RAM for the following elements:
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.
pTLI+ uses caller's stack for temporary storage and automatic variables. It requires 2K stack usage.
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.
Copyright © 1996, Integrated Systems, Inc. All rights reserved.