未验证 提交 498844ef 编写于 作者: O openharmony_ci 提交者: Gitee

!407 fix: 提高watcher_dog 的优先级

Merge pull request !407 from 熊磊/init311_1
......@@ -23,7 +23,10 @@ if (defined(ohos_lite)) {
"//base/startup/init_lite/interfaces/innerkits/include",
]
deps = [ "//base/startup/init_lite/services/log:init_log" ]
defines = [ "_GNU_SOURCE" ]
defines = [
"_GNU_SOURCE",
"OHOS_LITE_WATCHDOG",
]
if (ohos_kernel_type == "linux") {
defines += [ "LINUX_WATCHDOG" ]
}
......
......@@ -15,8 +15,10 @@
#include <errno.h>
#include <fcntl.h>
#include <sched.h>
#include <stdlib.h>
#include <sys/ioctl.h>
#include <sys/resource.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <time.h>
......@@ -75,7 +77,13 @@ int main(int argc, const char *argv[])
gap = (gap > 0) ? gap : DEFAULT_GAP;
INIT_LOGI("watchdoge started (interval %d, margin %d), fd = %d\n", interval, gap, fd);
#ifdef OHOS_LITE_WATCHDOG
#ifndef LINUX_WATCHDOG
if (setpriority(PRIO_PROCESS, 0, 14) != 0) { // 14 is process priority
INIT_LOGE("setpriority failed err=%d\n", errno);
}
#endif
#endif
int timeoutSet = interval + gap;
int timeoutGet = 0;
int ret = ioctl(fd, WDIOC_SETTIMEOUT, &timeoutSet);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册