测试当前Linux 内存页大小 的一个C程序

本文介绍了如何在Red Hat Enterprise Linux AS release 4 (Nahant Update 3) 系统中确定页面大小。通过使用 gcc 编译简单的 C 语言程序以及 getconf 命令获取了系统的页面大小为 4096 字节。

linux版本:

[oracle@redhat ~]$ cat /etc/redhat-release
Red Hat Enterprise Linux AS release 4 (Nahant Update 3)
[oracle@redhat ~]$ uname -a
Linux redhat 2.6.9-34.EL

[oracle@redhat ~]$ lsb_release -a
LSB Version: :core-3.0-ia32:core-3.0-noarch:graphics-3.0-ia32:graphics-3.0-noarch
Distributor ID: RedHatEnterpriseAS
Description: Red Hat Enterprise Linux AS release 4 (Nahant Update 3)
Release: 4
Codename: NahantUpdate3

程序代码:

#include
int main(int argc, char *)
{
printf("System page size: %d ",getpagesize());
}

测试:

[oracle@redhat ~]$ gcc -o testMem testMem.c
[oracle@redhat ~]$ ./testMem
System page size: 4096

linux提供的另外的一个命令:

[root@redhat ~]# getconf PAGE_SIZE
4096


来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/37724/viewspace-152626/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/37724/viewspace-152626/

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值