[ros-kernel] Advice needed: thread termination, APCs

Ge van Geldorp gvg at reactos.com
Tue Sep 14 19:37:03 CEST 2004


I think I better understand what's going on now, and even better, how to
fix it. I found a nice article at
http://www.windevnet.com/documents/s=7653/win0211b/0211b.htm
(registration required) explaining APCs and their relation with
KeAttachProcess()/KeDetachProcess().

After reading the article and looking at our code, it became obvious to
me that we have a bug in KeInsertQueueApc(). We're currently adding the
APC to the list at TargetThread->ApcState, but we should be adding it to
TargetThread->ApcStatePointer[Apc->ApcStateIndex]. Since
Apc->ApcStateIndex is set to OriginalApcEnvironment for the thread
termination APC, everything works ok after making this fix to
KeInsertQueueApc().

Since I'm still far from being an APC expert, I've attached my proposed
change to ke/apc.c, covering the KeInsertQueueApc() change above plus
some bug fixes for list handling and would like to ask the real APC
experts (Gunnar?) to review it.

Gé van Geldorp.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: apc.diff
Type: application/octet-stream
Size: 3667 bytes
Desc: not available
Url : http://reactos.com:8080/pipermail/ros-kernel/attachments/20040914/a0693332/apc.obj


More information about the Ros-kernel mailing list