ADTast-experimentalenumpthread-emulationqualifiedEnum
Last change
on this file since 41870a5 was
aaf92de,
checked in by Thierry Delisle <tdelisle@…>, 4 years ago
|
Moved coroutine to global scope to ease debugging
|
-
Property mode set to
100644
|
File size:
875 bytes
|
Line | |
---|
1 | #include <fstream.hfa> |
---|
2 | #include <kernel.hfa> |
---|
3 | #include <stdlib.hfa> |
---|
4 | #include <thread.hfa> |
---|
5 | #include <time.hfa> |
---|
6 | |
---|
7 | #define __kick_rate 150000ul |
---|
8 | #include "long_tests.hfa" |
---|
9 | |
---|
10 | #ifndef PREEMPTION_RATE |
---|
11 | #define PREEMPTION_RATE 10`ms |
---|
12 | #endif |
---|
13 | |
---|
14 | Duration default_preemption() { |
---|
15 | return PREEMPTION_RATE; |
---|
16 | } |
---|
17 | |
---|
18 | #ifdef TEST_LONG |
---|
19 | static const unsigned long N = 600_000ul; |
---|
20 | #else |
---|
21 | static const unsigned long N = 1_000ul; |
---|
22 | #endif |
---|
23 | |
---|
24 | coroutine Coroutine {}; |
---|
25 | |
---|
26 | void main(Coroutine& this) { |
---|
27 | while(true) { |
---|
28 | #if !defined(TEST_FOREVER) |
---|
29 | sout | "Coroutine 1"; |
---|
30 | #endif |
---|
31 | yield(); |
---|
32 | #if !defined(TEST_FOREVER) |
---|
33 | sout | "Coroutine 2"; |
---|
34 | #endif |
---|
35 | suspend; |
---|
36 | } |
---|
37 | } |
---|
38 | |
---|
39 | |
---|
40 | Coroutine c; |
---|
41 | int main(int argc, char* argv[]) { |
---|
42 | for(int i = 0; TEST(i < N); i++) { |
---|
43 | #if !defined(TEST_FOREVER) |
---|
44 | sout | "Thread 1"; |
---|
45 | #endif |
---|
46 | resume(c); |
---|
47 | #if !defined(TEST_FOREVER) |
---|
48 | sout | "Thread 2"; |
---|
49 | #endif |
---|
50 | yield(); |
---|
51 | KICK_WATCHDOG; |
---|
52 | } |
---|
53 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.