RE: [ntdev] Re: terminating a system threadAlso such thread termination can leave the memory allocations by this thread as orphaned.
Thread running in the kernel cannot be abruptly terminated. It can be terminated only if:
a) it returns to user mode
OR
b) it wants to terminate itself.
Otherwise, you will have kernel memory leaks.
Max
----- Original Message -----
From: Jeseem S
To: NT Developers Interest List
Sent: Thursday, May 17, 2001 4:05 PM
Subject: [ntdev] Re: terminating a system thread
Hmm…
Good idea I never thought about this.
However their is one flaw.
PsTerminateSystemThread can only be executed at passive level and not at APC level.
Regards
Jeseem
mailto:xxxxx@hotmail.com
----- Original Message -----
From: Hrdina Pavel
To: NT Developers Interest List
Sent: Thursday, May 17, 2001 5:15 PM
Subject: [ntdev] Re: terminating a system thread
You aren’t right. It is generally possible to kill a thread from some other
thread. The only thing you have to do is to force the thread to call the
PsTerminateSystemThread. And I think there is a mechanism especially
for doing a call to your routine in the context of some concrete thread - APC.
I have this implemented using two undocumented routines:
KeInitializeApc and KeInsertQueueApc.
Paul
-----Original Message-----
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com]On Behalf Of Jeseem S
Sent: Thursday, May 17, 2001 11:59 AM
To: NT Developers Interest List
Subject: [ntdev] Re: terminating a system thread
You can’t terminate any thread made in kernel mode from another thread.
So the only option is to implement some logic like Satish has pointed out.
Warm Regards
Jeseem
mailto:xxxxx@hotmail.com
“Some people think, Others think they think, Most of them don’t even think
of thinking.”
----- Original Message -----
From: “Satish”
To: “NT Developers Interest List”
Sent: Thursday, May 17, 2001 10:47 AM
Subject: [ntdev] Re: terminating a system thread
>
> BOOLEAN bTerminateThread = FALSE ;
>
> Inside Thread :
> while ( !bTerminateThread )
> {
> Do Anything…
> }
>
>
> In Other function :
> bTerminateThread = TRUE ; // If u want to terminate thread at any time.
>
> Follow like normal Win32 API thread methods only.
>
> Regards,
> Satish K.S
>
>
> > Hi,
> > I create a system thread using PsCreateSystemThread() system call. This
> > thread is continuously processing some data and can not wait for any
other
> > event. But based on some other even in my driver, I want to kill this
> thread
> > from some other function/thread. The system call
PsTerminateSystemThread()
> > won’t help as it can be called from within the thread which need to be
> > terminated.
> >
> > How can I terminate such a thread from another thread or function in my
> > driver?
> >
> > Also why doesn’t Ndis provide any such mechanism of creating/terminating
> > system threads?
> >
> > thanks
> > Raj
> >
_________________________________________________________________________
> > Get Your Private, Free E-mail from MSN Hotmail at
http://www.hotmail.com.
> >
> >
> > —
> > You are currently subscribed to ntdev as: xxxxx@aalayance.com
> > To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com
>
>
> —
> You are currently subscribed to ntdev as: xxxxx@hotmail.com
> To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com
>
—
You are currently subscribed to ntdev as: xxxxx@compelson.com
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com
—
You are currently subscribed to ntdev as: xxxxx@hotmail.com
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com
—
You are currently subscribed to ntdev as: xxxxx@storagecraft.com
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com
—
You are currently subscribed to ntdev as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com