Created
January 6, 2018 20:14
-
-
Save jlisic/1cc6c6504e2f102efa469c20245c7b7b to your computer and use it in GitHub Desktop.
A simple program that shows the impact of meltdown.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* a simple program that invokes the kernel */ | |
#define _GNU_SOURCE | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <sys/syscall.h> | |
#include <linux/random.h> | |
int main() { | |
/* declare our data */ | |
size_t i,n = 10000000; | |
void * random_buffer = NULL; | |
random_buffer = malloc(8); | |
for(i=0;i<n;i++) | |
syscall( SYS_getrandom, random_buffer, 8, GRND_NONBLOCK); | |
free(random_buffer); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Compile as:
gcc -O1 meltdown_test.c
time run as:
time ./a.out