source: src/tests/concurrent/coroutineYield.c@ 47498bd

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
RevLine 
[82c948c]1#include <fstream>
2#include <kernel>
3#include <stdlib>
4#include <thread>
[b9da9585]5#include <time>
6
[7bdcac1]7#include "long_tests.h"
8
[b9da9585]9#ifndef PREEMPTION_RATE
10#define PREEMPTION_RATE 10`ms
11#endif
12
13Duration default_preemption() {
14 return PREEMPTION_RATE;
15}
[82c948c]16
[7bdcac1]17#ifdef TEST_LONG
[70969f8]18static const unsigned long N = 600_000ul;
19#else
20static const unsigned long N = 1_000ul;
21#endif
22
[82c948c]23coroutine Coroutine {};
24
25void main(Coroutine& this) {
[7323573]26 while(true) {
27 sout | "Coroutine 1" | endl;
28 yield();
29 sout | "Coroutine 2" | endl;
30 suspend();
31 }
[82c948c]32}
33
34
35int main(int argc, char* argv[]) {
36 Coroutine c;
[7bdcac1]37 for(int i = 0; TEST(i < N); i++) {
[7323573]38 sout | "Thread 1" | endl;
39 resume(c);
40 sout | "Thread 2" | endl;
41 yield();
[7bdcac1]42 KICK_WATCHDOG;
[7323573]43 }
[82c948c]44}
Note: See TracBrowser for help on using the repository browser.