User Tools

Site Tools


realtime:documentation:howto:applications:memory:mlockall_globals_sample

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
realtime:documentation:howto:applications:memory:mlockall_globals_sample [2017/06/09 02:33]
jithu code modified as per coding conventions
realtime:documentation:howto:applications:memory:mlockall_globals_sample [2017/06/10 00:28] (current)
jithu
Line 42: Line 42:
  static int init;  static int init;
  struct rusage rusage;​  struct rusage rusage;​
- 
  
  getrusage(RUSAGE_SELF,​ &​rusage);​  getrusage(RUSAGE_SELF,​ &​rusage);​
Line 66: Line 65:
 { {
  int unexpected_pagefaults_detected;​  int unexpected_pagefaults_detected;​
- int actual_page_size;​ 
  int lock_memory = 1;  int lock_memory = 1;
  int buff_value;  int buff_value;
Line 83: Line 81:
  }  }
  (void)dump_page_faults();​ /* Set the baseline*/  (void)dump_page_faults();​ /* Set the baseline*/
- 
- /* printf something so we avoid introducing a page fault simply 
- * by performing the potentially first printf call. 
- */ 
- actual_page_size = sysconf(_SC_PAGESIZE);​ 
- 
- printf("​Page size = %d\n", actual_page_size);​ 
- 
- (void)dump_page_faults();​ 
  
  /* From this point onwards we no longer expect any page faults */  /* From this point onwards we no longer expect any page faults */
Line 106: Line 95:
  unexpected_pagefaults_detected = 1;  unexpected_pagefaults_detected = 1;
  
- glob_buffer[(i*PAGE_SZ) + 1] = 1;+ glob_buffer[(i * PAGE_SZ) + 1] = 1;
  if (dump_page_faults()) {  if (dump_page_faults()) {
  printf("​Writing to page %d of global buffer caused page fault(s)\n",​  printf("​Writing to page %d of global buffer caused page fault(s)\n",​
Line 115: Line 104:
  
  printf("​Done,​ result: %s\n",  printf("​Done,​ result: %s\n",
- unexpected_pagefaults_detected ? "​failed":"​success"​);​ + unexpected_pagefaults_detected ? "​failed"​ : "​success"​);​ 
- return unexpected_pagefaults_detected ? 1:0;+ return unexpected_pagefaults_detected ? 1 : 0;
 } }
  
 </​code>​ </​code>​
realtime/documentation/howto/applications/memory/mlockall_globals_sample.1496975598.txt.gz · Last modified: 2017/06/09 02:33 by jithu