diff options
| author | zy <[email protected]> | 2023-11-21 04:43:30 -0500 |
|---|---|---|
| committer | zy <[email protected]> | 2023-11-21 04:43:30 -0500 |
| commit | 8fc4155b733b4527c48e463daff2b0d0d78040e5 (patch) | |
| tree | 874050c0da79b52c94d1d168b2176a9341da34cc /testcase | |
| parent | 6c105992fd9a97da2c059e67ff24476fd6dacb67 (diff) | |
userstack
Diffstat (limited to 'testcase')
| -rw-r--r-- | testcase/userstack.c | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/testcase/userstack.c b/testcase/userstack.c new file mode 100644 index 0000000..ad6d4ba --- /dev/null +++ b/testcase/userstack.c @@ -0,0 +1,35 @@ +#include <stdio.h> +#include <unistd.h> + +void customFunction1(int n); +void customFunction2(int n); +void customFunction3(int n); + +void customFunction1(int n) { + if(n <= 0) { + printf("End of recursion\n"); + while (1) { + // sleep(1); + } // never return, keep stack + return; + } else { + printf("Calling customFunction2\n"); + customFunction2(n-1); + } +} + +void customFunction2(int n) { + printf("Calling customFunction3\n"); + customFunction3(n); +} + +void customFunction3(int n) { + printf("Calling customFunction1\n"); + customFunction1(n); +} + +int main() { + customFunction1(10); + + return 0; +}
\ No newline at end of file |
