Prev: [Job] Symantec - Senior Software Engineer - Mountain View, CA
Next: Why SetupDiEnumDeviceInterfaces fails after SetupDiGetClassDevs success?
From: Ira Baxter on 9 Aug 2010 16:57 We have an application in which one thread can stop another to inspect its state, by doing SuspendThread/GetThreadContext/ResumeThread. Extremely rarely, on a multicore system, GetThreadContext returns error code 5 (Windows system error code "Access Denied"). We are checking the return status of SuspendThread and ResumeThread; they aren't complaining, ever. How can it be the case that I can suspend a thread, but can't access its context? This blog http://www.dcl.hpi.uni-potsdam.de/research/WRK/2009/01/what-does-suspendthread-really-do/ suggests that SuspendThread, when it returns, may have *started* the suspension of the other thread, but that thread hasn't yet suspended. In this case, I can kind of see how GetThreadContext would be problematic, but this seems like a stupid way to define SuspendThread. (How would the call of SuspendThread know when the target thread was actaully suspended?) Any help appreciated. -- IDB
From: Daniel Terhell on 11 Aug 2010 06:28
The suspended thread might be temporarily "borrowed" for APC execution. This might or might not be the problem and it might even stop threads from suspending. What I would do is try it N times in a loop and sleep if it fails. //Daniel "Ira Baxter" <idbaxter(a)semdesigns.com> wrote in message news:e$QsMWAOLHA.5624(a)TK2MSFTNGP02.phx.gbl... > We have an application in which one thread can stop another to inspect its > state, > by doing SuspendThread/GetThreadContext/ResumeThread. > > Extremely rarely, on a multicore system, > GetThreadContext returns error code 5 (Windows system error code "Access > Denied"). > We are checking the return status of SuspendThread and ResumeThread; they > aren't complaining, ever. > > How can it be the case that I can suspend a thread, but can't access its > context? > > This blog > http://www.dcl.hpi.uni-potsdam.de/research/WRK/2009/01/what-does-suspendthread-really-do/ > > > > suggests that SuspendThread, when it returns, may have *started* the > suspension of the other > > thread, but that thread hasn't yet suspended. In this case, I can kind of > see how GetThreadContext > > would be problematic, but this seems like a stupid way to define > SuspendThread. > > (How would the call of SuspendThread know when the target thread was > actaully suspended?) > > > > Any help appreciated. > > > > -- IDB > > > > |