In function _beginthread, what does the second argument (stack_size) mean?
Stack size of where? And what does the default value (0) mean?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The stack size of where?
The call stack is a stack that maintains information about active function calls of executing software. It’s also known as an execution stack, control stack, or run-time stack. In multi-threaded software, each thread has its own call stack.
The primary purpose of the call stack is to manage control flow by keeping track of where each function call returns to. When a function call is made, a new stack frame is pushed onto the stack for that function. When the function returns, its stack frame is popped off and control flow is returned to the address of the caller’s next instruction.
A stack frame typically includes:
Parameters can also be passed via CPU registers, but there are drawbacks to this (ie. limited number of parameters, & registers may be needed for computation.)
Similarly, all local variables don’t have to be allocated on the current stack frame. Languages that support closures require free variables to survive after function return, yet locals on the call stack are deallocated when the current stack frame is popped off and control is returned to the caller.
My point here is that parameter passing and allocation of locals are determined by language and compiler implementation; you shouldn’t assume they always exist on the stack.
What does stack_size mean? What is the default value 0?
From the MSDN documentation on _beginthread, found under the Remarks section: