Skip to content

Instantly share code, notes, and snippets.

@Pithikos
Last active October 6, 2016 19:06
Show Gist options
  • Save Pithikos/624198ae875ac802870a7a5659c50e73 to your computer and use it in GitHub Desktop.
Save Pithikos/624198ae875ac802870a7a5659c50e73 to your computer and use it in GitHub Desktop.
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <unistd.h>
/*
Malloc memory of argv sizes with an interval of 10ms in between.
*/
int main(int argc, char **argv)
{
int i, j, memsize;
int *mems[100];
struct timespec ms10;
ms10.tv_sec = 0;
ms10.tv_nsec = 10000000;
i = 0;
for(i; i < argc-1; i++){
memsize = atoi(argv[i+1]);
mems[i] = malloc(memsize*sizeof(int));
j = 0;
for (j; j < memsize; j++){
mems[i][j] = j;
}
nanosleep(&ms10, NULL);
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment