INtime SDK Help
GetRtSystemMemoryInfo
INtime SDK v7.1 > About INtime > INtime Kernel > Memory management > GetRtSystemMemoryInfo

Returns information about the physical system memory configuration for the local node.

BOOLEAN GetRtSystemMemoryInfo(
    DWORD dwMemtype, 
    LPVOID pMemoryInfo
);

Parameters

dwMemtype
A value which indicates which type of information to return.
pMemoryInfo
A pointer to a structure where the information is to be returned, depending on the value of dwMemType.

Remarks

 The following values of dwMemtype are defined and are shown with their companion structure definition.

dwMemType Structure used Description
GET_SYSTEM_MEMORY_AREA_LIST
typedef struct tagSystemMemoryInfo {
    DWORD count;
    struct physical_memory_area_desc {
        QWORD area_base;
        QWORD area_size;
        DWORD area_flags;
    } area[1];
} SYSTEM_MEMORY_INFO;
Returns a list of memory areas assigned to the current node by Windows. This applies to INtime for Windows nodes only.
Set the value of the count field to the number of elements available in the array area[]. On return the count field is updated and the elements of the array are filled in with the area information.
Use this call to locate unmanaged memory areas to be managed by your application directly.

The area_flags field indicates the type of memory area:

  • A value of 0 (zero) indicates that the area is managed by the kernel
  • A value of 1 indicates that the area may be managed by the user directly
  • Any other value means that the area is used by the system.
GET_SYSTEM_MEMORY_POOL_LIST
typedef struct tagSystemMemoryInfo {
    DWORD count;
    struct physical_memory_area_desc {
        QWORD area_base;
        QWORD area_size;
        DWORD area_flags;
    } area[1];
} SYSTEM_MEMORY_INFO;
Returns a list of memory pools managed by the current node. This applies to both INtime for Windows and INtime Distributed RTOS nodes.
Set the value of the count field to the number of elements available in the array area[]. On return the count field is updated and the elements of the array are filled in with the pool information.
The area_flags field is not set by this subfunction.

All other values of dwMemtype are reserved for future use.

Return Values

TRUE
Success.
FALSE
Failure. To determine the status, call GetLastRtError.

Example

The following sample illustrates how to use the call with the GET_SYSTEM_MEMORY_AREA_LIST information type.

GetRtSystemMemoryInfo sample
Copy Code
#include <stdio.h>
#include <rt.h>

int main(int argc, char* argv[])
{
    SYSTEM_MEMORY_INFO smi, *smip;
    DWORD i, n;

    // Start with a buffer for a single area
    // Initialize the count to 1
    smi.count = 1;
    if (GetRtSystemMemoryInfo(GET_SYSTEM_MEMORY_AREA_LIST, &smi)) {
        // the call returns the number of areas available
        n = smi.count;
        if (n > 1) {
            // now get the data for all of the areas
            smip = malloc(4+(sizeof(smi.area)*n));
            smip->count = n;
            if (!GetRtSystemMemoryInfo(GET_SYSTEM_MEMORY_AREA_LIST, smip)) {
                printf("Failed to GetRtSystemMemoryInfo: %04x\n", GetLastRtError());
                return 1;
            }
        }
        else {
            smip = &smi;
        }
        for (i = 0; i < smip->count; i++) {
            printf("Pool %u: base %05x_%08x size %llu MB flags=%u\n",
                i, (DWORD)(smip->area[i].area_base>>32), (DWORD)(smip->area[i].area_base), smip->area[i].area_size/0x100000, smip->area[i].area_flags);
        }
    }
    else {
        printf("Could not GetRtSystemMemoryInfo: %04x\n", GetLastRtError());
    }

    return 0;
}

Status

E_PARAM
The value of dwMemtype is not valid.
E_NOT_SUPPORTED
The value of dwMemtype is not supported in this configuration.
E_BAD_ADDR
the pMemoryInfo pointer is not a valid address for writable memory.

Requirements

Versions Defined in Include Link to
INtime 6.2 intime/rt/include/rtbase.h rt.h rt.lib
See Also