suspend/resume Posix thread

suspend/resume Posix thread

Post by Wasi » Tue, 12 Dec 2006 20:08:20


How can i wait on a particular conditional variable for suspend/resume
Posix thread (C++) ??? and r there any functions for
suspending/resuming posix threads ??? if not how can i implement this
behavior??? thanx.
 
 
 

suspend/resume Posix thread

Post by Joe Seig » Tue, 12 Dec 2006 20:25:53


Suspend/resume used to be part of Java. They deprecated it as it couldn't
be reliably used for anything useful. Suspend/resume isn't part of
Posix.

So the question is, what are you doing that needs an unreliable
mechanism to implement it with?


--
Joe Seigh

When you get lemons, you make lemonade.
When you get hardware, you make software.

 
 
 

suspend/resume Posix thread

Post by Wasi » Tue, 12 Dec 2006 20:55:08


well the requirement is; whenever user presses pause, thread(s) running
should pause(sleep) and resume whenever the user wants to.(by pressing
resume). How can i implement this???
 
 
 

suspend/resume Posix thread

Post by Joe Seig » Tue, 12 Dec 2006 21:56:13


Well, SIGSTOP and SIGCONT can be used to suspend and resume a process.
You could do the equivalent on a per thread basis by using signals and
have the threads do a pause() or sigsuspend() in the signal handler in
order to wait for a "resume" signal.

Being able to suspend a thread means that the thread has to be in effect
async-safe at all times. So among other things, the thread can't use
locks shared by non suspended threads, or call functions that use such
locks, ever. How sure are you that all of the threads in question meet
this criteria? None of them call any GUI functions that use private internal
GUI locks that by definition you won't be aware of? Kind of hard to get
any effect from pressing the "resume" button if the GUI is locked up.

--
Joe Seigh

When you get lemons, you make lemonade.
When you get hardware, you make software.
 
 
 

suspend/resume Posix thread

Post by Wasi » Wed, 13 Dec 2006 14:36:13


First, thanx for ur suggestions. I have to pause the entire process
means the main thread as well as all the other child thread(s) that are
running and then resuming all. So there will be no such case of some
threads running and some other in suspended state.
 
 
 

suspend/resume Posix thread

Post by Joe Seig » Wed, 13 Dec 2006 21:04:26


Well, signal the process with SIGSTOP and SIGCONT then.


--
Joe Seigh

When you get lemons, you make lemonade.
When you get hardware, you make software.
 
 
 

suspend/resume Posix thread

Post by Eric Sosma » Wed, 13 Dec 2006 21:54:04


If all the process' threads are suspended, what thread
handles the pressing of "resume?"

--
Eric Sosman
XXXX@XXXXX.COM
 
 
 

suspend/resume Posix thread

Post by Joe Seig » Wed, 13 Dec 2006 22:33:21


I figured he was talking about a separate process, especially since
he's been told about this problem. But since his earlier examples
use pthread_kill, I suspect this is not the case. This ought to be
fun to watch.

--
Joe Seigh

When you get lemons, you make lemonade.
When you get hardware, you make software.
 
 
 

suspend/resume Posix thread

Post by Wazz » Thu, 14 Dec 2006 13:45:50


Actually i want the main thread to continue and all the threads to stop
and then resume whem main thread send them the sigcont signal. How can
i do that as sigstop suspends all threads including parent thread.
 
 
 

suspend/resume Posix thread

Post by Eric Sosma » Thu, 14 Dec 2006 23:40:33


Then why did you write (in the portion you snipped)

> [...] I have to pause the entire process
> means the main thread as well as all the other child thread(s)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> that are running [...]

? No, don't answer: It's what we call a "rhetorical question,"
intended not to gather information from you but to draw your
attention to some point. And the point I'm trying to highlight
is that you seem quite confused about your own requirements: You
don't really appear to know what you want to do. You have gone
from an foggy idea of your strategic goal to a concrete question
about a particular tactic you sort of think might be useful in
some way you don't quite comprehend ...

There was once a newspaper comic strip featuring a bratty
little boy who asked his mother "Do we have any chain saws?"
"No, why?" she replied. "Shucks!" said he, "How am I going to
learn to juggle?"

Wasim, your situation is a little bit like that of the boy
in the comic strip: You have gotten far ahead of yourself, and
you need to go back and pay attention to the fundamentals. In
the case at hand, you need to make some decisions about program
structure (are you using one process with multiple threads, or
multiple processes with one thread each, or multiple processes
with multiple threads each), and about implementation (are you
in a position to insert code into these threads you'd like to
make idle, or are they "uncooperative"), and so on. Suspending
a thread without its cooperation is dangerous -- like juggling
chain saws, it's not the place to start. Seek alternatives.

--
Eric Sosman
XXXX@XXXXX.COM