krnl 1
Loading...
Searching...
No Matches
kernelmoviesimple.ino
Go to the documentation of this file.
1#include <krnl.h>
2
3
4// an simple example with KeRNeL
5// http://www.control.aau.dk/~jdn/edu/doc/kernels/arduino
6// Just one task looping and waiting on a Dikstra semaphore
7// It timeout and to serial printing
8// br Jens
9
10struct k_t *sem, *task;
11
13{
14 while (1) {
15 k_wait(sem,50); // wait up to 50 ticks and timeout
16 Serial.println("tik ");
17 }
18}
19
20char stak[100];
21void setup()
22{
23 Serial.begin(9600);
24 k_init(5,5,5);
25 task = k_crt_task(taskBody,10,stak,100);
26 sem = k_crt_sem(0,10);
27 Serial.println("just bef starting");
28 k_start(10); // start KeRNeL with tickspeed 10 msec
29 Serial.println("you should no come here - ");
30}
31
32void loop()
33{
34 // dead function - will never be called
35}
36
char stak[100]
Definition k02.ino:12
int k_wait(struct k_t *sem, int timeout)
stand wait on semaphore call with timeout facility
Definition krnl.c:683
struct k_t * k_crt_task(void(*pTask)(void), char prio, char *pStk, int stkSize)
create a task - only to be called before k_start creates a task and put it in the active Q
Definition krnl.c:328
struct k_t * k_crt_sem(int init_val, int maxvalue)
change task priority and reinserts it in task Q and do a task shift
Definition krnl.c:544
int k_init(int nrTask, int nrSem, int nrMsg)
Definition krnl.c:1108
int k_start()
Definition krnl.c:1149
struct k_t * sem
Definition mutex.ino:3
void setup()
struct k_t * task
void loop()
void taskBody()
Definition krnl.h:323