Linux Newbie help
 help / color / mirror / Atom feed
* suspending a thread and executing it later
@ 2003-01-18 16:33 Lee Chin
  0 siblings, 0 replies; 2+ messages in thread
From: Lee Chin @ 2003-01-18 16:33 UTC (permalink / raw)
  To: hahn, linux-newbie

Hi,
Here is what I want to do... in my program, I want to arbitrarily in some function suspend the execution of the current (self) thread and schedule my self to resume from that point later.

In my program, I only have 2 threads... and lets say thread 1 ends up calling a function foo() that will block on IO.  I dont want to make the whole system block, so I want to resume the execution of foo() when the IO completes and restore thread state so that the stack (function call history and all) is maintained.

How can I do this in Linux?

Thanks
Lee
-- 
__________________________________________________________
Sign-up for your own FREE Personalized E-mail at Mail.com
http://www.mail.com/?sr=signup

Meet Singles
http://corp.mail.com/lavalife

-
To unsubscribe from this list: send the line "unsubscribe linux-newbie" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs

^ permalink raw reply	[flat|nested] 2+ messages in thread
* Re: suspending a thread and executing it later
@ 2003-01-20  5:29 Lee Chin
  0 siblings, 0 replies; 2+ messages in thread
From: Lee Chin @ 2003-01-20  5:29 UTC (permalink / raw)
  To: sos22, linux-newbie

Do pthreads and getcontext/setcontext work nicely with each other?

Thanks
Lee
----- Original Message -----
From: Steven Smith <sos22@cam.ac.uk> 
Date: Sat, 18 Jan 2003 17:46:44 +0000
To: Lee Chin <leechin@mail.com>
Subject: Re: suspending a thread and executing it later

> > Here is what I want to do... in my program, I want to arbitrarily in
> > some function suspend the execution of the current (self) thread and
> > schedule my self to resume from that point later.
> Have a look at ``info libc "Non Local Exits" "System V Contexts"''.
> The basic idea is to have one ucontext per thread.  When the running
> thread wants to block, it picks some other thread, and then
> swapcontext()s with it.
> 
> > In my program, I only have 2 threads... and lets say thread 1 ends
> > up calling a function foo() that will block on IO.  I dont want to
> > make the whole system block, so I want to resume the execution of
> > foo() when the IO completes and restore thread state so that the
> > stack (function call history and all) is maintained.
> The easy way to do this is via pthreads, but if you really want to
> do it yourself, you'll probably need to set every file descriptor
> to non-block mode, and then swapcontext() whenever an IO
> function returns EAGAIN.
> 
> Steven Smith,
> sos22@cam.ac.uk.

-- 
__________________________________________________________
Sign-up for your own FREE Personalized E-mail at Mail.com
http://www.mail.com/?sr=signup

Meet Singles
http://corp.mail.com/lavalife

-
To unsubscribe from this list: send the line "unsubscribe linux-newbie" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2003-01-20  5:29 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-01-18 16:33 suspending a thread and executing it later Lee Chin
  -- strict thread matches above, loose matches on Subject: below --
2003-01-20  5:29 Lee Chin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox