ebruakagunduz

swap cache test

Feb 18th, 2015
181
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.07 KB | None | 0 0
  1. #include <stdlib.h>
  2.  
  3. int main() {
  4. int *memory_area1 = malloc(819200000);
  5. int *p;
  6.  
  7. int i, j = 0;
  8. for (i = 0; i < 200000; i++) {
  9. /* write per 4kB, 1024*4byte */
  10. memory_area1[j] = 1;
  11. j += 1024;
  12. }
  13.  
  14.  
  15. printf("First 800MB allocated\n");
  16. sleep(10);
  17. printf("After 600 seconds start to read first area\n");
  18. sleep(600);
  19. printf("Ten seconds ..\n");
  20. sleep(10);
  21. printf("Starting..\n");
  22. /* read or write every integer to do swapped in */
  23.  
  24. *memory_area1 = 1;
  25. memory_area1 += 1024;
  26. *memory_area1 = 1;
  27. memory_area1 += 1024;
  28. for (i = 0; i < 25000; i++) {
  29. /* 1024*4bytes = 4kB write */
  30. *memory_area1 = 1;
  31. memory_area1 += 2048;
  32. /* 1024*4bytes = 4kB read */
  33. *p = *memory_area1;
  34. memory_area1 += 2048;
  35. }
  36. printf("Read is completed\n");
  37. getchar();
  38. return 0;
  39. }
Advertisement
Add Comment
Please, Sign In to add comment