c - Segmentation fault (core dumped) error while trying to flush cache -


i trying out ways of measuring tlb size on machine. somehow needed ensure cpu not cache elements of array using measure average access time per page. tried code inside loop have, using answer on here:

file *fp; fp = fopen("/proc/sys/vm/drop_caches", "w");  fprintf(fp, "3");  fclose(fp); 

however, getting segmentation fault (core dumped) error. have no idea why happening. not c , appreciated. thanks.

be sure check whether open of file successful, since writing system file, requires run in privileged mode.

file *fp; fp = fopen("/proc/sys/vm/drop_caches", "w"); if (fp == null) {     printf("error %d: %s\n", errno, strerror(errno));     // error handling, exit or return } fprintf(fp, "3");  fclose(fp); 

Comments

Popular posts from this blog

javascript - How to get current YouTube IDs via iMacros? -

c# - Maintaining a program folder in program files out of date? -

emulation - Android map show my location didn't work -