How to know the size of page frame used by my OS?

2

1

How to know the size of page frame used by my OS ?

This could be useful for some optimizations when I code. (Allocate big buffer that fit in a page frame for example).

Page frame is determined by the operating system ? Mine is Windows 7 (but impossible to find information about it on Google. So, may be I wrong...)

user17208

Posted 2014-04-30T09:04:45.557

Reputation: 23

Answers

3

If you are just using Windows, you can use the following C snippet to get the page size:

#include <stdio.h>
#include <windows.h>

int main(void) {
    SYSTEM_INFO si;
    GetSystemInfo(&si);

    printf("The page size for this system is %u bytes.\n", si.dwPageSize);

    return 0;
}

(from: http://en.wikipedia.org/wiki/Page_%28computer_memory%29#Windows-based_operating_systems)

On Linux you can find the page size by getting the PAGESIZE configuration parameter from the kernel:

mtak@frisbee:~$ getconf PAGESIZE
4096

(or you can use the getpagesize() system call).

mtak

Posted 2014-04-30T09:04:45.557

Reputation: 11 805

Perfect ! So I can find it at runtime. Thank you ! – user17208 – 2014-04-30T13:09:40.470