Any way to suspend/resume running thread?

Hi,

is there any way to suspend/resume running system thread that was created
with PsCreateSystemThread()? Will undocomented ZwSuspendThread() and
ZwResumeThread() work in this case of are they for Native API
RtlCreateUserThread() only? Any ideas?

Thanks for help!

Anton Kolomyeytsev

No. These functions trigger suspend on return to user mode, which
never occurs for a system thread.
So, you must design your own mechanism - like waiting on some events.

Max

----- Original Message -----
From: “Anton Kolomyeytsev”
To: “NT Developers Interest List”
Sent: Sunday, December 15, 2002 4:16 AM
Subject: [ntdev] Any way to suspend/resume running thread?

> Hi,
>
> is there any way to suspend/resume running system thread that was
created
> with PsCreateSystemThread()? Will undocomented ZwSuspendThread() and
> ZwResumeThread() work in this case of are they for Native API
> RtlCreateUserThread() only? Any ideas?
>
> Thanks for help!
>
> Anton Kolomyeytsev
>
> —
> You are currently subscribed to ntdev as: xxxxx@storagecraft.com
> To unsubscribe send a blank email to %%email.unsub%%
>

Max,

thanks a lot for your reply! Is this (waiting on some events) should be
done
inside a thread? The problem is (just as with previous “send-send-recv”
topic) I do write wrapper for thr_suspend(), thr_contiune() and all of
thr_Xxx. No access to the thread code…

I’ve checked ReactOS source code and they do queue special APC inside the
PsSuspendThread() and PsResumeThread(). Is this a good idea to do the
same? Just do not want to try if somebone who is treated as “trusted
person” tried and failed -)

Thanks a lot!

Anton Kolomyeytsev

No. These functions trigger suspend on return to user mode, which
never occurs for a system thread.
So, you must design your own mechanism - like waiting on some events.

Max

----- Original Message -----
From: “Anton Kolomyeytsev”
> To: “NT Developers Interest List”
> Sent: Sunday, December 15, 2002 4:16 AM
> Subject: [ntdev] Any way to suspend/resume running thread?
>
>
> > Hi,
> >
> > is there any way to suspend/resume running system thread that was
> created
> > with PsCreateSystemThread()? Will undocomented ZwSuspendThread() and
> > ZwResumeThread() work in this case of are they for Native API
> > RtlCreateUserThread() only? Any ideas?
> >
> > Thanks for help!
> >
> > Anton Kolomyeytsev
> >
> > —
> > You are currently subscribed to ntdev as: xxxxx@storagecraft.com
> > To unsubscribe send a blank email to %%email.unsub%%
> >

> inside a thread? The problem is (just as with previous
“send-send-recv”

topic) I do write wrapper for thr_suspend(), thr_contiune() and all
of
thr_Xxx. No access to the thread code…

Suspending a thread is evil, even if possible technically. It has huge
deadlock potential. So, first “park” the thread in some known piece of
code, and then force it to wait on event. Why you need suspend in
iSCSI code anyway?

BTW - that’s why Sun removed thread suspending from Java in some
revision. Too deadlock-prone.

Max

Max,

what about adding/removing the threads from LIST_ENTRY located at offset
40 at undocumented KPROCESS structure? Seems to work… At least in the
current builds ) Did you ever try this?

I do not have access to the code that runs inside the thread ( All I have
to write now is POSIX compatible threads. Have no idea why to
suspend/resume them.

Anton Kolomyeytsev

Suspending a thread is evil, even if possible technically. It has huge
deadlock potential. So, first “park” the thread in some known piece of
code, and then force it to wait on event. Why you need suspend in
iSCSI code anyway?

BTW - that’s why Sun removed thread suspending from Java in some
revision. Too deadlock-prone.

Max

> to write now is POSIX compatible threads. Have no idea why to

Wow… good luck implementing condvars. :slight_smile:

Max

This is what KeWaitXxx() does; correct? Removes the thread from the run
list until an event is signaled?

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Anton Kolomyeytsev
Sent: Sunday, December 15, 2002 12:49 PM
To: NT Developers Interest List
Subject: [ntdev] Re: Any way to suspend/resume running thread?

Max,

what about adding/removing the threads from LIST_ENTRY located at offset
40 at undocumented KPROCESS structure? Seems to work… At least in the
current builds ) Did you ever try this?

I do not have access to the code that runs inside the thread ( All I
have
to write now is POSIX compatible threads. Have no idea why to
suspend/resume them.

Anton Kolomyeytsev

Suspending a thread is evil, even if possible technically. It has huge
deadlock potential. So, first “park” the thread in some known piece of
code, and then force it to wait on event. Why you need suspend in
iSCSI code anyway?

BTW - that’s why Sun removed thread suspending from Java in some
revision. Too deadlock-prone.

Max


You are currently subscribed to ntdev as: xxxxx@storagecraft.com
To unsubscribe send a blank email to %%email.unsub%%

Maxim S. Shatskih wrote:

>inside a thread? The problem is (just as with previous

“send-send-recv”

>topic) I do write wrapper for thr_suspend(), thr_contiune() and all

of

>thr_Xxx. No access to the thread code…

Suspending a thread is evil, even if possible technically. It has huge
deadlock potential. So, first “park” the thread in some known piece of
code, and then force it to wait on event. Why you need suspend in
iSCSI code anyway?

BTW - that’s why Sun removed thread suspending from Java in some
revision. Too deadlock-prone.

Max

I’m with Max on this. I have seen applications lock up completely when
a thread is suspended holding a resource of some kind, and then the
thread which requested the suspend waits on the same resource.

Andy.