-
-
Save chrishiestand/6382962 to your computer and use it in GitHub Desktop.
This file contains 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
#include <unistd.h> | |
#include <stdlib.h> | |
#include <stdio.h> | |
main(argc,argv) | |
int argc; | |
char **argv; | |
{ | |
char *array; | |
unsigned long long int n_bytes,t,i,j; | |
if(argc < 3) | |
{ | |
printf("\nUsage: %s n_bytes sleep_time\n\n",argv[0]); | |
exit(1); | |
} | |
n_bytes = strtoull(argv[1],NULL,10); | |
t = strtoul(argv[2],NULL,10); | |
printf("allocating %llu bytes...\n",n_bytes); | |
if ((array=(char *)malloc(n_bytes*sizeof(char)))==NULL) { | |
fprintf(stderr, "File %s, Line %ld: Out of memory while allocating %llu bytes.\n", __FILE__, (long)__LINE__, n_bytes); | |
exit(1); | |
} | |
printf("writing %llu bytes...\n",n_bytes); | |
for (i=0;i<n_bytes;i++) { | |
array[i] = i; | |
} | |
printf("reading %llu bytes...\n",n_bytes); | |
for (i=0;i<n_bytes;i++) { | |
j=array[i]; | |
} | |
printf("sleeping for %u seconds...\n",t); | |
sleep(t); | |
exit(0); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment