#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <sys/mman.h>
void usage() {
cout << "Read the source, young Luke!\n";
}
main(int argc, char *argv[]) {
int size = 20 * 1024 * 1024;
// allocate the pages
char *ptr = (char *)malloc(size);
if (ptr == 0) {
perror("Error in malloc");
exit(1);
}
// touch every page
for(int i = 0; i < size; i++)
ptr[i] = 0;
// Lock the pages
int ret = mlock(ptr, size);
if (ret != 0) {
perror("Mlock");
exit(1);
}
while (1)
sleep(1);
}
-- ======================================================================== || Randy Appleton, Professor of Computer Science at Northern Michigan || || University. And a big fan of Linux! || ================= mailto:randy@euclid.nmu.edu ==========================
- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/