📄 rt_process.c
字号:
#ifndef MODULE#define MODULE#endif#include <linux/module.h>#include <linux/kernel.h>#include <linux/version.h>#include <linux/cons.h>#include "rt_sched.h"#define NTASKS 5RT_TASK tasks[NTASKS];struct { int id; int compute; int period;} Parameters[NTASKS];void fun(int delay) { int cycle,i; while(1){ for (cycle=0; cycle < delay; cycle++){ for (i=0; i<1000; i++); } rt_task_wait(); }}int init_module(void){ RTIME now; int x; Parameters[0].compute=10; Parameters[0].period=3000; Parameters[1].compute=20; Parameters[1].period=4200; Parameters[2].compute=30; Parameters[2].period=4300; Parameters[3].compute=40; Parameters[3].period=4500; Parameters[4].compute=50; Parameters[4].period=4700; Parameters[5].compute=60; Parameters[5].period=5100; for (x=0; x<NTASKS; x++){ rt_task_init(&(tasks[x]), fun, Parameters[x].compute , 3000, x+1); } now = rt_get_time(); for (x=0; x<NTASKS; x++){ rt_task_make_periodic(&(tasks[x]), now+(RTIME)1000, (RTIME) Parameters[x].period); } return 0;}void cleanup_module(void){ int x; for (x=0; x<NTASKS; x++){ rt_task_delete(&(tasks[x])); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -