Re: When to disable/enable APCs?

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



This documentation is just plain wrong. Ctrl+C is handled entirely in user
mode; CSRSS creates a thread in the process receiving the Ctrl+C event that
calls a handler function in kernel32. This handler function calls the list
of registered handlers that applications have registered with kernel32 and
possibly performs the default action for Ctrl+C (killing the app).

There is no special kernel mode logic to support this. I don't know where
that particular piece of documentation originated, but as far as I know the
reality is that Ctrl+C is an entirely user mode concept handled by CSRSS.

--
Ken Johnson (Skywing)
Windows SDK MVP

"Steve Dispensa" <dispensa@xxxxxxxxxxxxxxxxxxxx> wrote in message
news:C0E70412.15716%dispensa@xxxxxxxxxxxxxxxxxxxxxxx
No, it doesn't, ctrl+c is special:

"The Alertable parameter specifies whether the thread can be alerted and
its
wait state aborted by an alert originating from an undocumented internal
kernel routine or by a user-mode APC. If the value of Alertable is FALSE
then the thread cannot be alerted, no matter what the value of the
WaitMode
parameter or the origin of the alert. The only exception to this rule is
that of a terminating thread. A thread is automatically made alertable,
for
instance, when terminated by a user with a Ctrl+C."

Reference:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/kernel_d/hh
/Kernel_d/Synchro_c88e3997-b7c1-494d-983b-2a69b229a904.xml.asp


There is a good paper with some relevant commentary here:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dndevice/ht
ml/Locks_Sync.asp

-Steve


On 7/21/06 8:10 PM, in article qlu2c2t0andn07ovqdcbsjaci58ku6mi74@xxxxxxx,
"BubbaGump" <BubbaGump> wrote:

Never mind this one. Sorry. I think I know the answer, that it
depends on whether a wait is alertable or not.




On Fri, 21 Jul 2006 20:45:54 -0400, BubbaGump <> wrote:

Speaking of disabling a thread (suspending or killing?), what happens
to the thread of a command-line application if someone presses CTRL-C
while it's waiting on a lock? Is the CTRL-C ignored, processed
immediately, or processed after the lock is acquired?




On Fri, 21 Jul 2006 17:00:13 -0700, "Doron Holan [MS]"
<doronh@xxxxxxxxxxxxxxxxxxxx> wrote:

typically you leave APCs enabled. you disalbe them when you are
holding a
lock while still at passive level. for instance, if you are using a
KEVENT
to synchronize access, you want to disable APCs before acquiring it.
the
reason you disable APCs inthis case is that the thread can be disabled
(via
an APC) while holding the lock and never resumed, thus orphaning the
lock

d




.



Relevant Pages

  • Re: spin lock
    ... is a signal handler, which executes periodically on a timer signal. ... Below is test code to illustrate a possible solution using spin-lock. ... The ratio of lock acquisitions for the handler and the foreground task ...
    (comp.lang.forth)
  • [git patches] ocfs2 and configfs updates
    ... lock migration race fixes. ... Most forms of migration had been temporarily ... disabled in the ocfs2 dlm due to those problems, ... Added post handler callable function in o2net message handler ...
    (Linux-Kernel)
  • Re: LOR with sysctl lock
    ... sysctl lock is the first lock in any hierarchy, ... SYSCTL_PROC handler can take any locks it wants, ... called with the sysctl lock held shared. ... device detach routine destroys the device softc and schedules sysctl ...
    (freebsd-arch)
  • Re: kqueue disable on delivery...
    ... The first is EV_DOD, aka disable on delivery. ... (Reallocation of the knote is also lock intensive, ... it's too implementation specific flag. ... a timeout handler for the connection) poses to be a problem. ...
    (freebsd-current)
  • Re: kqueue disable on delivery...
    ... The first is EV_DOD, aka disable on delivery. ... (Reallocation of the knote is also lock intensive, ... it's too implementation specific flag. ... a timeout handler for the connection) poses to be a problem. ...
    (freebsd-arch)