ebruakagunduz

thp_tester.c

Jan 8th, 2015
181
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.25 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. int main() {
  5. int *memory_area1 = malloc(819200000);
  6. int *memory_area2 = malloc(819200000);
  7. int *memory_area3 = malloc(819200000);
  8. int *p;
  9.  
  10. int i, j = 0;
  11. for (i = 0; i < 200000; i++) {
  12. /* write per 4kB, 1024*4byte */
  13. memory_area1[j] = 1;
  14. j += 1024;
  15. }
  16. j = 0;
  17. printf("First 800MB allocated\n");
  18. sleep(10);
  19.  
  20. for (i = 0; i < 200000; i++) {
  21. memory_area2[j] = 1;
  22. j += 1024;
  23. }
  24. j = 0;
  25. printf("Second 800MB allocated\n");
  26. sleep(10);
  27.  
  28. for (i = 0; i < 200000; i++) {
  29. memory_area3[j] = 1;
  30. j += 1024;
  31. }
  32. printf("Third 800MB allocated\n");
  33.  
  34. sleep(15);
  35. printf("Start to flush third area is flushing .. \n");
  36. free(memory_area3);
  37. printf("Flush is completed\n");
  38. printf("Start to read first area\n");
  39. sleep(15);
  40. for (i = 0; i < 204800000; i++) {
  41. *p = *memory_area1;
  42. memory_area1++;
  43. }
  44. printf("Read is completed\n");
  45.  
  46. getchar();
  47. return 0;
  48. }
Advertisement
Add Comment
Please, Sign In to add comment