1. getconf PAGESIZE/PAGE_SIZE 返回值单位为Bytes
点击(此处)折叠或打开
- [root@localhost nginx-1.8.0]# getconf PAGESIZE
- 4096
- [root@localhost nginx-1.8.0]# getconf PAGE_SIZE
- 4096
#include
int getpagesize(void);返回值单位为Bytes
点击(此处)折叠或打开
- The function getpagesize() returns the number of bytes in a page, where a "page" is the thing used where it says in the description of mmap(2) that files are mapped in page-sized units.
-
- The size of the kind of pages that mmap() uses, is found using
-
- #include <unistd.h>
- long sz = sysconf(_SC_PAGESIZE);
-
- (where some systems also allow the synonym _SC_PAGE_SIZE for _SC_PAGESIZE), or
-
- #include <unistd.h>
- int sz = getpagesize()
点击(此处)折叠或打开
- [root@localhost test]# more pagesize.c
- #include <unistd.h>
- #include <stdio.h>
- int main(int argc, char *argv[])
- {
- printf("linux page size is %d bytes",getpagesize());
- return 0;
- }
点击(此处)折叠或打开
- [root@localhost test]# gcc -g pagesize.c -o pagesize -Wall
- [root@localhost test]# ./pagesize
- linux page size is4096 bytes