Connaitre le page size de sa machine
From Deimos.fr / Bloc Notes Informatique
1 Determining the Page Size
Most operating systems allow programs to determine what the page size is so that they can allocate memory more efficiently.
1.1 UNIX and POSIX-based Operating Systems
UNIX and POSIX-based systems use the C function sysconf().
Edit a test.c file and paste it :
<nowiki> #include <stdio.h> // printf(3) #include <unistd.h> // sysconf(3) int main(void) { printf("The page size for this system is %ld bytes\n", sysconf(_SC_PAGESIZE)); //_SC_PAGE_SIZE is OK too. return 0; } </nowiki>
Then compile it with gcc :
gcc -o test test.c
Now launch it :
# ./test The page size for this system is 4096 bytes
1.2 Win32-based Operating Systems (Windows 9x, NT, ReactOS)
Win32-based operating system use the C function GetSystemInfo() function in kernel32.dll
<nowiki> #include <windows.h> SYSTEM_INFO si; GetSystemInfo(&si); printf("The page size for this system is %u bytes\n", si.dwPageSize); </nowiki>