核心编程中关于线程的一段话没看懂,该如何解决
核心编程中关于线程的一段话没看懂
第六章6.6节
Notice that within BaseThreadStart, the thread calls either ExitThread or ExitProcess. This means that the thread cannot ever exit this function; it always dies inside it. This is why BaseThreadStart is prototyped as returning VOID—it never returns. //不返回是什么意思?
Also, your thread function can return when it 's done processing because of BaseThreadStart. When BaseThreadStart calls your thread function, it pushes its return address on the stack so your thread function knows where to return. //返回地址放在了线程栈的什么位置?
But BaseThreadStart is not allowed to return. If it didn 't forcibly kill the thread and simply tried to return, an access violation would almost definitely be raised because there is no function return address on the thread 's stack and BaseThreadStart would try to return to some random memory location.
------解决方案--------------------
1. 就是说这个函数永远不允许走到最后一步return, 总是在之前已经ExitThread或ExitProcess
2. 就跟一般的函数调用一样啊, 在ESP上的四个字节, 位于压栈的最后一个参数下面(这里只有一个参数)
------解决方案--------------------
找个中文版看下下嘛,
同意楼上的。
第六章6.6节
Notice that within BaseThreadStart, the thread calls either ExitThread or ExitProcess. This means that the thread cannot ever exit this function; it always dies inside it. This is why BaseThreadStart is prototyped as returning VOID—it never returns. //不返回是什么意思?
Also, your thread function can return when it 's done processing because of BaseThreadStart. When BaseThreadStart calls your thread function, it pushes its return address on the stack so your thread function knows where to return. //返回地址放在了线程栈的什么位置?
But BaseThreadStart is not allowed to return. If it didn 't forcibly kill the thread and simply tried to return, an access violation would almost definitely be raised because there is no function return address on the thread 's stack and BaseThreadStart would try to return to some random memory location.
------解决方案--------------------
1. 就是说这个函数永远不允许走到最后一步return, 总是在之前已经ExitThread或ExitProcess
2. 就跟一般的函数调用一样啊, 在ESP上的四个字节, 位于压栈的最后一个参数下面(这里只有一个参数)
------解决方案--------------------
找个中文版看下下嘛,
同意楼上的。