By using this site, you agree to our Privacy Policy and our Terms of Use. Close
MisterBlonde said:
@crashman

For the most part your right. When a caller calls another function the called function's entry point moves to the top of the stack (each thread has it's own call stack). Eip and esp are changed to reflect this. Therefore the caller HAS to wait until the called function returns even if doesn't need the return value. The called function needs to be popped off the stack before eip can be updated with the original caller's instruction. Each thread has a single stack, and each processor has only one eip, ebp, esp, etc..

The only way a calling function can continue execution prior to the called function completing is if it makes a call asynchronously to code/function running on another thread.

For the code you mentioned, the only way multiple cores can speed it up is if somehow funb, func, or fund spawn their own threads. If they don't then funa will run on a single thread which will be affinitized to the same processor.

No, he's not. In practice, most C compilers will keep the function parameters in registers and will not actually push them onto the call stack. On the intel machine you are talking about if you were to write a piece of inline assembly the function parameters will be stored in EAX, EBX, etc.