小编Xuc*_*ang的帖子

什么是64位机器中的最大文件映射大小

我是64位架构的新手.你能告诉我64位linux机器中文件映射支持的MAX文件大小吗?我想通过文件映射打开超过20GB的文件,是否可用?

我写了一个示例代码.但是当我在GBSIZE偏移量中获得指针的值时,它会导致总线错误:

unsigned char* pCur = pBegin + GBSIZE;
//pBegin is the pointer returned by mmap
printf("%c",*pCur); 
Run Code Online (Sandbox Code Playgroud)

BTW,printf("%c",*pBegin );工作正常.和我的地址大小:38位物理,48位虚拟

这是完整的代码:

#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/mman.h>

//#define FILEPATH "smallfile"
#define FILEPATH "bigfile"
#define GBSIZE (1024L*1024L*1024L)
#define TBSIZE (1024L*GBSIZE)
#define NUMSIZE  (20L * GBSIZE)
//#define NUMSIZE  (10)
#define FILESIZE (NUMINTS * sizeof(int))

int main(int argc, char *argv[])
{
    int i;
    int fd;
    unsigned char *pBegin;

    fd = open(FILEPATH, O_RDONLY); …
Run Code Online (Sandbox Code Playgroud)

linux 64-bit filemap

4
推荐指数
3
解决办法
7228
查看次数

标签 统计

64-bit ×1

filemap ×1

linux ×1