1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
|
#ifndef MODULE
#define MODULE
#endif
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/version.h>
#include <linux/errno.h>
#include <linux/cons.h>
#include <rtl_sched.h>
#include <rtl_fifo.h>
#include <math.h>
#define DOSIN 1
#define DOCOS 2
double cosradians = 0;
RT_TASK tasks[2];
void fun(int t) {
double radians = 0;
double result;
while(radians < 100){
if(t == DOSIN)result = sin(radians);
else result= cos(radians);
rtf_put(t, &result, sizeof(result));
radians += 1.0;
conpr(( (t == DOSIN)? "S":"C"));
rt_task_wait();
}
}
int init_module (void)
{
rtf_create (DOSIN, 4000);
rtf_create (DOCOS, 4000);
rt_task_init (&tasks[0], fun, DOSIN, 3000, 4);
rt_task_use_fp (&tasks[0], 1);
rt_task_make_periodic (&tasks[0], rt_get_time (), 5000);
conpr ("First started\n");
rt_task_init (&tasks[1], fun, DOCOS, 3000, 5);
rt_task_use_fp (&tasks[1], 1);
rt_task_make_periodic (&tasks[1], rt_get_time (), 5000);
conpr ("Second started\n");
return 0;
}
void cleanup_module (void)
{
rtf_destroy (1);
rtf_destroy (2);
rt_task_delete (&tasks[0]);
rt_task_delete (&tasks[1]);
}
|