51 lines1.1 KB
Newer
Older
-
+
commited
{line.log.rev}
on
9 months ago
37
1
#include <stdio.h>
2
#include <stddef.h>
3
#include "coroutine.h"
4
#include "generator.h"
5
#include "asleep.h"
6
#include "task.h"
7
8
#include <dirent.h>
9
#include <string.h>
10
#include <stdlib.h>
11
#include <time.h>
12
13
14
void *chaindeeper(void *param){
15
// enough headroom for printf on an Intel Mac - your system may be different
16
if (Coroutine_GetStackHeadroom() < 2000){
6 months ago
17
void *result;
18
bool fail = Coroutine_Chain(chaindeeper, param, &result);
19
return fail ? NULL : result;
9 months ago
37
20
}
8 months ago
21
printf("%ld %ld\n", (long)param, Coroutine_GetStackHeadroom());
9 months ago
37
22
long depth = (long)param;
23
if (depth > 10000){
24
return NULL;
25
}
26
return chaindeeper((void *)(depth + 1));
27
}
28
29
30
void *chaintest(
31
void *param
32
){
33
(void)param;
34
35
chaindeeper((void *)0);
36
37
return param;
38
}
39
40
41
int main(int argc, char *argv[]) {
42
(void)argc;
43
(void)argv;
44
45
Coroutine_StartSystem();
6 months ago
46
Coroutine_Run(chaintest, NULL, NULL);
9 months ago
37
47
Coroutine_Report report = Coroutine_StopSystem();
48
7 months ago
49
printf("%d routines using a pool of %d, min headroom %d\n", report.coroutines_created, report.coroutines_pool_size, report.lowest_headroom);
9 months ago
37
50
}
51