ebruakagunduz

swap_cache_test, skip some pages

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