unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
* Guile threads vs GTK loop
@ 2004-07-31 11:26 Ondrej Zajicek
  2004-08-15 10:53 ` Andy Wingo
  0 siblings, 1 reply; 2+ messages in thread
From: Ondrej Zajicek @ 2004-07-31 11:26 UTC (permalink / raw)


Hello

I would like to use Guile (v1.6.4) in GTK app and i want running guile threads
while GTK main event loop is still active. If i execute from C code
begin-thread and return to C code, thread don't get any processor time. I can
call scm_yield() in GTK idle handler (handler called when no events are
available) to give some processor time to scheme threads, but i don't know
whether there are any running threads (i don't want call scm_yield() if there
aren't any).

Does anybody knows:

- How i can ask whether there are any running guile threads?
  (To deinstall idle handler where there aren't any.)
- How i can be informed (some hook?) whether any new running guile thread
  appeared? (To reinstall idle handler.)
  
- My Guile-exported C subroutines aren't reentrant. Is there a need to use any
locking? Happen guile thread switches even during call to C subroutines?

-- 
Elen sila lumenn' omentielvo

Ondrej 'SanTiago' Zajicek (email: santiago@mail.cz, jabber: santiago@njs.netlab.cz)
OpenPGP encrypted e-mails preferred (KeyID 0x11DEADC3, wwwkeys.pgp.net)
"To err is human -- to blame it on a computer is even more so."


_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-user


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

* Re: Guile threads vs GTK loop
  2004-07-31 11:26 Guile threads vs GTK loop Ondrej Zajicek
@ 2004-08-15 10:53 ` Andy Wingo
  0 siblings, 0 replies; 2+ messages in thread
From: Andy Wingo @ 2004-08-15 10:53 UTC (permalink / raw)


Hey Ondrej,

On Sat, 31 Jul 2004, Ondrej Zajicek wrote:

> - How i can ask whether there are any running guile threads?
>   (To deinstall idle handler where there aren't any.)

I think that single-active-thread?, although not documented, will do
what you want.

> - How i can be informed (some hook?) whether any new running guile thread
>   appeared? (To reinstall idle handler.)

You'll have to write this layer yourself, I think.

Is it really a big performance impact? I would avoid this complexity.
Perhaps you know something I don't :)

> - My Guile-exported C subroutines aren't reentrant. Is there a need to use any
> locking? Happen guile thread switches even during call to C subroutines?

"Do guile thread switches happen ..." :-)

I don't think so. Thread switches can happen when threads are created,
when mutices and signals are operated on, when scm_yield is called, when
SCM_ALLOW_INTS is called, and when SCM_TICK is called. That's not an
exhaustive list. SCM_TICK is called frequently by the evaluator, and is
the result of most thread switches. [Corrolary: `yield' is called all
the time, with little impact in the single-threaded case. Why bother
with removing the idle handler? It should be a timeout handler, btw;
unless you want it to eat all of the CPU.]

So no, there is no signal that drives thread switches. I think that a
call to a C subroutine would block the app. However, all of the above is
just from reading the source; I personally haven't used threading in 1.6.

Regards,
--
Andy Wingo <wingo@pobox.com>
http://ambient.2y.net/wingo/


_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-user


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

end of thread, other threads:[~2004-08-15 10:53 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-07-31 11:26 Guile threads vs GTK loop Ondrej Zajicek
2004-08-15 10:53 ` Andy Wingo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).