userstack
This commit is contained in:
35
testcase/userstack.c
Normal file
35
testcase/userstack.c
Normal file
@@ -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;
|
||||
}
|
||||
Reference in New Issue
Block a user