krnl 1
Loading...
Searching...
No Matches
k001timertest.ino
Go to the documentation of this file.
1/*****************************************************
2* TEST TEST TEST
3* krnl.c part of kernel KRNL *
4 * this version adapted for Arduino *
5* *
6* (C) 2012,2013,2014 *
7* *
8* Jens Dalsgaard Nielsen <jdn@es.aau.dk> *
9* http://es.aau.dk/staff/jdn *
10* Section of Automation & Control *
11* Aalborg University, *
12* Denmark *
13* *
14* "THE BEER-WARE LICENSE" (frit efter PHK) *
15* <jdn@es.aau.dk> wrote this file. As long as you *
16* retain this notice you can do whatever you want *
17* with this stuff. If we meet some day, and you think*
18* this stuff is worth it ... *
19* you can buy me a beer in return :-) *
20* or if you are real happy then ... *
21* single malt will be well received :-) *
22* *
23* Use it at your own risk - no warranty *
24* *
25* tested with duemilanove w/328, uno R3, *
26* seeduino 1280 and mega2560 *
27*****************************************************/
28
29
30/*
31First 50 mea without krnl 0.6% overhead
32Next 59 mea witrh krnl 4.1% overhead
33only one task created. more task and sem will increase overhead
34because more elm will be checked in timer isr
35
36Please note it is quite stable
37
38/Jens april 2015
39
40
411000 builtin/k-eat: 1005 / 1006
421000 builtin/k-eat: 1007 / 1006
431000 builtin/k-eat: 1006 / 1007
441000 builtin/k-eat: 1006 / 1005
451000 builtin/k-eat: 1006 / 1007
461000 builtin/k-eat: 1007 / 1006
471000 builtin/k-eat: 1005 / 1006
481000 builtin/k-eat: 1007 / 1006
491000 builtin/k-eat: 1006 / 1007
501000 builtin/k-eat: 1006 / 1006
511000 builtin/k-eat: 1007 / 1006
521000 builtin/k-eat: 1007 / 1007
531000 builtin/k-eat: 1006 / 1005
541000 builtin/k-eat: 1006 / 1007
551000 builtin/k-eat: 1007 / 1006
561000 builtin/k-eat: 1005 / 1006
571000 builtin/k-eat: 1007 / 1005
581000 builtin/k-eat: 1006 / 1007
591000 builtin/k-eat: 1006 / 1005
601000 builtin/k-eat: 1006 / 1006
611000 builtin/k-eat: 1007 / 1007
621000 builtin/k-eat: 1005 / 1005
631000 builtin/k-eat: 1007 / 1006
641000 builtin/k-eat: 1007 / 1006
651000 builtin/k-eat: 1005 / 1006
661000 builtin/k-eat: 1007 / 1005
671000 builtin/k-eat: 1006 / 1007
681000 builtin/k-eat: 1006 / 1005
691000 builtin/k-eat: 1006 / 1006
701000 builtin/k-eat: 1007 / 1006
711000 builtin/k-eat: 1005 / 1006
721000 builtin/k-eat: 1007 / 1006
731000 builtin/k-eat: 1006 / 1007
741000 builtin/k-eat: 1006 / 1007
751000 builtin/k-eat: 1007 / 1005
761000 builtin/k-eat: 1006 / 1007
771000 builtin/k-eat: 1006 / 1006
781000 builtin/k-eat: 1005 / 1006
791000 builtin/k-eat: 1007 / 1006
801000 builtin/k-eat: 1006 / 1007
811000 builtin/k-eat: 1006 / 1005
821000 builtin/k-eat: 1006 / 1007
831000 builtin/k-eat: 1007 / 1007
841000 builtin/k-eat: 1005 / 1006
851000 builtin/k-eat: 1007 / 1007
861000 builtin/k-eat: 1007 / 1006
871000 builtin/k-eat: 1005 / 1006
881000 builtin/k-eat: 1007 / 1006
891000 builtin/k-eat: 1006 / 1007
901000 builtin/k-eat: 1006 / 1005
91<<
921000 builtin/k-eat: 1042 / 1042
931000 builtin/k-eat: 1041 / 1042
941000 builtin/k-eat: 1042 / 1041
951000 builtin/k-eat: 1041 / 1041
961000 builtin/k-eat: 1041 / 1042
971000 builtin/k-eat: 1041 / 1040
981000 builtin/k-eat: 1041 / 1040
991000 builtin/k-eat: 1040 / 1040
1001000 builtin/k-eat: 1040 / 1041
1011000 builtin/k-eat: 1042 / 1041
1021000 builtin/k-eat: 1042 / 1041
1031000 builtin/k-eat: 1041 / 1042
1041000 builtin/k-eat: 1041 / 1042
1051000 builtin/k-eat: 1042 / 1041
1061000 builtin/k-eat: 1042 / 1041
1071000 builtin/k-eat: 1041 / 1042
1081000 builtin/k-eat: 1041 / 1042
1091000 builtin/k-eat: 1042 / 1041
1101000 builtin/k-eat: 1041 / 1040
1111000 builtin/k-eat: 1040 / 1041
1121000 builtin/k-eat: 1040 / 1041
1131000 builtin/k-eat: 1041 / 1040
1141000 builtin/k-eat: 1041 / 1041
1151000 builtin/k-eat: 1041 / 1042
1161000 builtin/k-eat: 1042 / 1041
1171000 builtin/k-eat: 1042 / 1041
1181000 builtin/k-eat: 1041 / 1041
1191000 builtin/k-eat: 1041 / 1042
1201000 builtin/k-eat: 1042 / 1041
1211000 builtin/k-eat: 1042 / 1041
1221000 builtin/k-eat: 1041 / 1042
1231000 builtin/k-eat: 1041 / 1041
1241000 builtin/k-eat: 1042 / 1040
1251000 builtin/k-eat: 1040 / 1040
1261000 builtin/k-eat: 1040 / 1041
1271000 builtin/k-eat: 1040 / 1041
1281000 builtin/k-eat: 1042 / 1041
1291000 builtin/k-eat: 1041 / 1041
1301000 builtin/k-eat: 1041 / 1042
1311000 builtin/k-eat: 1042 / 1041
1321000 builtin/k-eat: 1042 / 1041
1331000 builtin/k-eat: 1041 / 1041
1341000 builtin/k-eat: 1041 / 1042
1351000 builtin/k-eat: 1042 / 1041
1361000 builtin/k-eat: 1042 / 1041
1371000 builtin/k-eat: 1041 / 1041
1381000 builtin/k-eat: 1040 / 1041
1391000 builtin/k-eat: 1041 / 1040
1401000 builtin/k-eat: 1040 / 1040
1411000 builtin/k-eat: 1041 / 1042
142
143
144*/
145
146#include <i2a.h>
147
148#include <krnl.h>
149
150char a[10];
151
152void test (int msec)
153{
154 unsigned long t1, t2;
155 i2a(a, msec);
156
157 Serial.print(a);
158 Serial.print(" builtin/k-eat: ");
159 t1 = millis();
160 while (msec > 10) {
161 delayMicroseconds(10000);
162 msec -= 10;
163 }
164 delayMicroseconds(msec * 1000);
165 t2 = millis();
166 t2 -= t1;
167 ul2a(a, t2);
168 Serial.print(a);
169
170}
171
172void ktest(int msec)
173{
174 unsigned long t1, t2;
175
176 Serial.print(" / ");
177 t1 = millis();
178 k_eat_time(msec);
179 t2 = millis();
180 t2 -= t1;
181 ul2a(a, t2);
182 Serial.println(a);
183 k_eat_time(100); // wait på rs232
184}
185
186char s1[100];
187void t1()
188{
189 int i = 50;
190 while (i--) {
191 test(1000);
192 ktest(1000);
193 }
194 while (1);
195}
196
197
198void setup() {
199 // put your setup code here, to run once:
200 Serial.begin(9600);
201 for (int i = 0; i < 50; i++) {
202 test(1000);
203 ktest(1000);
204 }
205 Serial.println("<<");
206 k_init(1, 0, 0);
207 k_crt_task(t1, 10, s1, 100);
208 k_start(1);
209}
210
211void loop() {} // put your main code here, to run repeatedly:
212
213
volatile int i
unsigned char s1[110]
Definition k03asleep.ino:25
char a[150]
void delayMicroseconds(unsigned int t)
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
int k_init(int nrTask, int nrSem, int nrMsg)
Definition krnl.c:1108
int k_start()
Definition krnl.c:1149
void test(int msec)
void setup()
void ktest(int msec)
void t1()
void loop()
struct k_t * t1
Definition krnlgen.ino:3
struct k_t * t2
Definition krnlgen.ino:3