ADT
aaron-thesis
arm-eh
ast-experimental
cleanup-dtors
deferred_resn
demangler
enum
forall-pointer-decay
jacob/cs343-translation
jenkins-sandbox
new-ast
new-ast-unique-expr
no_list
persistent-indexer
pthread-emulation
qualifiedEnum
Last change
on this file since 47498bd was 7bdcac1, checked in by Thierry Delisle <tdelisle@…>, 7 years ago |
Added the option to make longrun tests run until failure
|
-
Property mode
set to
100644
|
File size:
699 bytes
|
Line | |
---|
1 | #include <fstream>
|
---|
2 | #include <kernel>
|
---|
3 | #include <stdlib>
|
---|
4 | #include <thread>
|
---|
5 | #include <time>
|
---|
6 |
|
---|
7 | #include "long_tests.h"
|
---|
8 |
|
---|
9 | #ifndef PREEMPTION_RATE
|
---|
10 | #define PREEMPTION_RATE 10`ms
|
---|
11 | #endif
|
---|
12 |
|
---|
13 | Duration default_preemption() {
|
---|
14 | return PREEMPTION_RATE;
|
---|
15 | }
|
---|
16 |
|
---|
17 | #ifdef TEST_LONG
|
---|
18 | static const unsigned long N = 600_000ul;
|
---|
19 | #else
|
---|
20 | static const unsigned long N = 1_000ul;
|
---|
21 | #endif
|
---|
22 |
|
---|
23 | coroutine Coroutine {};
|
---|
24 |
|
---|
25 | void main(Coroutine& this) {
|
---|
26 | while(true) {
|
---|
27 | sout | "Coroutine 1" | endl;
|
---|
28 | yield();
|
---|
29 | sout | "Coroutine 2" | endl;
|
---|
30 | suspend();
|
---|
31 | }
|
---|
32 | }
|
---|
33 |
|
---|
34 |
|
---|
35 | int main(int argc, char* argv[]) {
|
---|
36 | Coroutine c;
|
---|
37 | for(int i = 0; TEST(i < N); i++) {
|
---|
38 | sout | "Thread 1" | endl;
|
---|
39 | resume(c);
|
---|
40 | sout | "Thread 2" | endl;
|
---|
41 | yield();
|
---|
42 | KICK_WATCHDOG;
|
---|
43 | }
|
---|
44 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.