#include #include #include #include #include #include #include #include #include #include "libemm64.h" #include "emm64_syscall.h" char string[] = "Hello, world!"; int main(int ac, char *av[]) { int fd; u_int64_t addr; u_int64_t len = 5 * 1024 * 1024 * 1024ull; char *buf1, *buf2; int r; #ifdef BENCH u_int64_t start, end; int cnt; #endif fd = open("/dev/io", O_RDWR); fd = open("bigmap", O_RDWR | O_CREAT, 0666); ftruncate(fd, len); buf1 = malloc(131072); buf2 = malloc(131072); addr = mmap64(0, len, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0); printf("map addr = 0x%llx\n", addr); #ifdef BENCH for (cnt = 16; cnt <= 131072; cnt *= 2) { disable_intr(); bcopy64((u_long)buf1, addr, cnt); start = rdtsc(); bcopy64((u_long)buf1, addr, cnt); end = rdtsc(); enable_intr(); printf("ticks(64): %lld for %d bytes\n", end - start, cnt); disable_intr(); bcopy(buf1, buf2, cnt); start = rdtsc(); bcopy(buf1, buf2, cnt); end = rdtsc(); enable_intr(); printf("ticks(32): %lld for %d bytes\n", end - start, cnt); } #endif bcopy64((u_long)&string, addr, strlen(string)); r = msync64(addr, len, 0); if (r == -1) warn("msync64"); printf("pid: %d\n", getpid()); r = msync64((uintptr_t)&string, 4096, 0); if (r == -1) warn("msync64 - string"); r = msync(&string, 4096, 0); if (r == -1) warn("msync"); r = munmap64(addr, len); if (r == -1) warn("munmap64"); exit(0); }