* Suspend one thread and resume another in one system call ?
@ 2009-08-26 16:02 Nikita V. Youshchenko
2009-08-26 16:32 ` Bryan Donlan
0 siblings, 1 reply; 2+ messages in thread
From: Nikita V. Youshchenko @ 2009-08-26 16:02 UTC (permalink / raw)
To: linux-kernel; +Cc: Stas Bezzubtsev
Hello.
Consider a situation when:
- there is a set of threads,
- only one of those should be allowed to work at a time,
- there are "switch moments" when one thread should suspend, and other
(known) resume.
"Classic" solutions like have each thread sleeping on a semaphore, and
making switch operation "sem_post(next_sem); sem_wait(my_sem)" cause two
syscalls per switch.
Could anyone suggest a solution with only one kernel entry per switch -
running thread enters kernel and is de-scheduled, new thread resumes and
leaves kernel?
Nikita
P.S.
Since there are other threads in the same application working in the
parallel with the mentioned "exclusive set", user-space solutions like
libpth are not interesting.
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: Suspend one thread and resume another in one system call ?
2009-08-26 16:02 Suspend one thread and resume another in one system call ? Nikita V. Youshchenko
@ 2009-08-26 16:32 ` Bryan Donlan
0 siblings, 0 replies; 2+ messages in thread
From: Bryan Donlan @ 2009-08-26 16:32 UTC (permalink / raw)
To: Nikita V. Youshchenko; +Cc: linux-kernel, Stas Bezzubtsev
On Wed, Aug 26, 2009 at 12:02 PM, Nikita V. Youshchenko<yoush@cs.msu.su> wrote:
> Hello.
>
> Consider a situation when:
> - there is a set of threads,
> - only one of those should be allowed to work at a time,
> - there are "switch moments" when one thread should suspend, and other
> (known) resume.
>
> "Classic" solutions like have each thread sleeping on a semaphore, and
> making switch operation "sem_post(next_sem); sem_wait(my_sem)" cause two
> syscalls per switch.
>
> Could anyone suggest a solution with only one kernel entry per switch -
> running thread enters kernel and is de-scheduled, new thread resumes and
> leaves kernel?
>
> Nikita
>
> P.S.
> Since there are other threads in the same application working in the
> parallel with the mentioned "exclusive set", user-space solutions like
> libpth are not interesting.
If these threads are truly exclusive, just use ucontext.h's
setcontext() to switch threads in userspace.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2009-08-26 16:33 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-08-26 16:02 Suspend one thread and resume another in one system call ? Nikita V. Youshchenko
2009-08-26 16:32 ` Bryan Donlan
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.