In regards to C what is a stub routine? Also an example would be much appreciated as well.
In regards to C what is a stub routine? Also an example would be much appreciated as well.
In C\C++ we can have it as a safe mechanism when calling another function
void stub(void (*func)(int), int arg) {
(*func)(arg);
thread_exit(0);
}
The reason to not just call func is to ensure that once it's done running it doesn't return to the random value stored at the top of the stack especially without calling the thread_exit(0) function. So instead we can return to stub, which then calls thread_exit(0). func itself won't call thread_exit(0) let stub do it.