Last active
March 17, 2025 09:17
-
-
Save oleavr/a3d9d7322d5f2a1ad82c to your computer and use it in GitHub Desktop.
How to probe the total amount of physical memory on QNX
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdint.h> | |
#include <stdio.h> | |
#include <string.h> | |
#include <sys/syspage.h> | |
int | |
main(int argc, char *argv[]) | |
{ | |
struct asinfo_entry *entries = SYSPAGE_ENTRY(asinfo); | |
size_t count = SYSPAGE_ENTRY_SIZE(asinfo) / sizeof(struct asinfo_entry); | |
char *strings = SYSPAGE_ENTRY(strings)->data; | |
uint64_t total = 0; | |
size_t i; | |
for (i = 0; i < count; i++) { | |
struct asinfo_entry *entry = &entries[i]; | |
if (strcmp(strings + entry->name, "ram") == 0) { | |
total += entry->end - entry->start + 1; | |
} | |
} | |
printf("Total: %llu\n", total); | |
return 0; | |
} |
it is in bits. if you want to show in KB, you have to do printf("Total: %llu\n", total/(1024*8)).
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi oleavr, does this prints the total amount of physical memory on QNX in KB or just Bytes? Please confirm