File: rt_process.c

package info (click to toggle)
rtlinux 3.1pre3-3
  • links: PTS
  • area: non-free
  • in suites: etch, etch-m68k
  • size: 4,896 kB
  • ctags: 4,228
  • sloc: ansic: 26,204; sh: 2,069; makefile: 1,414; perl: 855; tcl: 489; asm: 380; cpp: 42
file content (84 lines) | stat: -rw-r--r-- 1,417 bytes parent folder | download | duplicates (2)
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
/*
 * RTLinux FPU test example
 *
 * Written by Michael Barabanov, 1998
 *  (C) FSMLabs  1999. baraban@fsmlabs.com
 *  Released under the GNU GENERAL PUBLIC LICENSE Version 2, June 1991
 */

#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/version.h>
#include <linux/cons.h>
#include <asm/io.h>

#include <rtl_sched.h>
#include <math.h>

RT_TASK mytask;
RT_TASK task2;
RT_TASK task3;

void fun (int t)
{
	int i = 0;
	double f = 0;
	while (1) {
/* 		conpr(t == 1 ? "1" : "2"); */
		i++;
		f++;
		if (i != f) {
			conpr("Task "); conprn (t);
			conpr(" FP error: i = "); conprn(i);
			conpr("f = "); conprn(f); conpr("\n");
			i = 0;
			f = 0;
		}
		if (i > 200000) {
			i = 0;
			f = 0;
		}
		rt_task_wait();
	}
/* 	conpr("The RT-task has stopped.\n"); */
}


void ifun (int t)
{
	int i=0;
	while (1) {
		if (i++ % 5000 == 0) {
/* 			conpr("i"); */
		}
		rt_task_wait();
	}
}


int init_module (void)
{
	RTIME now = rt_get_time ();

	rt_task_init (&mytask, fun, 1, 4000, 4);
	rt_task_use_fp (&mytask, 1);
	rt_task_make_periodic (&mytask, now + 1000, 3123);

	rt_task_init (&task2, fun, 2, 4000, 5);
	rt_task_use_fp (&task2, 1);
	rt_task_make_periodic (&task2, now + 1000, 4767);

	rt_task_init (&task3, ifun, 3, 4000, 3);
	rt_task_make_periodic (&task3, now + 1000, 300);

	return 0;
}


void cleanup_module (void)
{
	rt_task_delete (&mytask);
	rt_task_delete (&task2);
	rt_task_delete (&task3);
}