gpt4 book ai didi

Linux内核开发

转载 作者:塔克拉玛干 更新时间:2023-11-03 00:10:15 25 4
gpt4 key购买 nike

我想在系统启动后以及每 1000 毫秒(例如)在 Linux 内核中运行一些脚本/二进制文件(不使用软件作为 crontab 和内核模块)。我在哪里可以放置这样的代码:

#include <linux/kmod.h>

char *envp[] = { "HOME=/", NULL };
char *argv[] = { "/bin/ls", NULL };

call_usermodehelper(argv[0], argv, envp, UMH_WAIT_EXEC);

最佳答案

尝试使用内核定时器API:

https://www.ibm.com/developerworks/library/l-timers-list/

The simplest method is a call to setup_timer, which initializes the timer and sets the user-provided callback function and context. Otherwise, the user can set these values (function and data) in the timer and simply call init_timer. Note that init_timer is called internally by setup_timer"

void init_timer( struct timer_list *timer );
void setup_timer( struct timer_list *timer,
void (*function)(unsigned long), unsigned long data );

关于Linux内核开发,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38312724/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com