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

Load Balancing in Bluemix using custom domain and DNS SRV records -

oracle - pls-00402 alias required in select list of cursor to avoid duplicate column names -

python - Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>] error -