Re: KeSetEvent and context switches



Calin Iaru wrote:
Hi *,


I have a bug which seems to be related to context switches while doing a KeSetEvent. So, the code looks like this - 2 threads, one signals the second, and the second frees the event. It so happens that on Server 2003 x86, the second thread creates a new structure on the old event, and this corrupts the event's internal state on the first thread.
It seems that KeSetEvent is not atomic, and the DDK confirms it. It is quite strange that it does not appear on XP and W2K.

Let me know your thoughts on this,
Calin
I think you were just lucky on XP and W2K. Your design is wrong.
.



Relevant Pages

  • Re: KeSetEvent and context switches
    ... nature of this bug - either a resource leak or a context switch. ... have been a bad design to make the code "context switch dependent". ... It's a bit strange to have locks around KeSetEvent and ExFreePool. ...
    (microsoft.public.development.device.drivers)
  • Re: KeSetEvent and context switches
    ... switch bug that can harm KeSetEvent. ... It's a bit strange to have locks around KeSetEvent and ExFreePool. ... so that context switch may occur before KeSetEvent ...
    (microsoft.public.development.device.drivers)
  • Re: KeSetEvent and context switches
    ... Indeed, KeSetEvent() is not atomic - unless you have set Wait to TRUE, ... quite strange that it does not appear on XP and W2K. ... Furthermore, this bug has ... So, the code looks like this - 2 threads, one signals the second, ...
    (microsoft.public.development.device.drivers)