/* * thrash_start() * start paging in thrash process */ int thrash_start(void) { if (geteuid() != 0) { pr_inf("not running as root, ignoring --thrash option\n"); return -1; } if (thrash_pid) { pr_err("thrash background process already started\n"); return -1; } thrash_pid = fork(); if (thrash_pid < 0) { pr_err("thrash background process failed to fork: %d (%s)\n", errno, strerror(errno)); return -1; } else if (thrash_pid == 0) { #if defined(SCHED_RR) int ret; stress_set_proc_name("stress-ng-thrash"); ret = stress_set_sched(getpid(), SCHED_RR, 10, true); (void)ret; #endif while (g_keep_stressing_flag) { pagein_all_procs(); compact_memory(); merge_memory(); (void)sleep(1); } _exit(0); } return 0; }
bool PinyinPhraseLib::load_lib (const char *libfile, const char *pylibfile, const char *idxfile) { std::ifstream is_lib(libfile); std::ifstream is_pylib (pylibfile); std::ifstream is_idx (idxfile); if (!is_lib) return false; input (is_lib, is_pylib, is_idx); compact_memory (); return number_of_phrases () != 0; }