ebruakagunduz

swap_cache_test

Feb 16th, 2015
169
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.95 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. printf("First 800MB allocated\n");
  15. sleep(10);
  16. printf("After 600 seconds start to read first area\n");
  17. sleep(600);
  18. printf("Ten seconds ..\n");
  19. sleep(10);
  20. printf("Starting..\n");
  21. /* read or write every integer to do swapped in */
  22.  
  23. for (i = 0; i < 100000; i++) {
  24. /* 1024*4bytes = 4kB read */
  25. *p = *memory_area1;
  26. memory_area1 += 1024;
  27. /* 1024*4bytes = 4kB write */
  28. *memory_area1 = 1;
  29. memory_area1 += 1024;
  30. }
  31. printf("Read is completed\n");
  32. getchar();
  33. return 0;
  34. }
Advertisement
Add Comment
Please, Sign In to add comment