From: Marius Vollmer <marius.vollmer@uni-dortmund.de>
Subject: About cleaning up the thread stuff
Date: Tue, 18 Jan 2005 16:54:43 +0100 [thread overview]
Message-ID: <lj3bwyzq9o.fsf@troy.dt.e-technik.uni-dortmund.de> (raw)
Hi,
I am now turning to go over the thread stuff in Guile, first to
understand what we have, and then to maybe clean it up and document it
authoritatively.
I'd like to give you advance warning of where I am heading at the
moment so that you can talk me out of doing the wrong things. All of
this might change as I make up my mind, but please comment anyway.
I do the work on the 'branch_mvo-thread-cleanup' branch.
- First, I want to rip out the plugin interface since it confuses me
a bit. Maybe I'll put it back in later, but to get started, I only
want to deal with POSIX pthreads. Guile will be able to use
pthreads, but can also be compiled without pthreads.
I consider the pthread API to be the plugin interface where
different threading implementations can be selected. Maybe it is
useful to make the names configurable that Guile uses for the
pthread API, but it should always be a pthread API.
- Then I want to specify clearly the two modes that a program can be
in: 'guile mode' and 'non-guile mode'. In guile mode, a program
can use functions from the Guile API and must play by the rules of
Guile, in non-guile mode, it can not call Guile functions (safe a
very few exceptions) but does not need to play by the rules.
The rules are basically that a thread must periodically execute
SCM_TICK and must only block in functions provided by Guile. If
you want to block in other ways, you must first leave guile mode
(and enter again after blocking). Stack frames that are created in
non-guile mode are not scanned by the GC so you can not store SCM
values in them.
You can enter guile mode in any thread, but Guile offers
convenience functions for creating threads that start out in Guile
mode. When a thread first enters guile mode, it gets a 'guile
personality' and shows up in (all-threads), for example. When it
leaves guile mode, it keeps this personality and is only removed
from (all-threads) when it terminates.
- For Scheme (and also for C code that wants to use them), I want to
offer 'fat' mutexes and condition variables.
These are mutexes and condvars that are as nice as reasonable: they
are fair, you can query easily where threads are blocking, asyncs
are handled while blocking, dead-locks might be detected and
mutexes can be recursive, for example.
No other kinds of mutexes are offered, for example, all mutexes
used by Scheme code will be of this 'fat' kind. (The low level C
API will disappear.) If you want to use pthread mutexes, you can,
but you must leave guile mode while blocking on them.
To make this easy, there will be functions like
scm_pthread_mutex_lock that is just like pthread_mutex_lock but
will properly leave guile mode while blocking.
(The only advantage that pthread mutexes have over these 'fat' ones
is that they are slightly faster and slightly smaller. I don't
consider these reasons good enough to lose the advantages of the
fat ones.)
_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-devel
next reply other threads:[~2005-01-18 15:54 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-01-18 15:54 Marius Vollmer [this message]
2005-01-18 17:00 ` About cleaning up the thread stuff Marius Vollmer
2005-01-18 18:03 ` Julian Graham
2005-01-18 21:03 ` Marius Vollmer
2005-01-18 18:08 ` Andy Wingo
2005-01-18 21:04 ` Marius Vollmer
2005-01-18 22:02 ` Kevin Ryde
2005-01-18 23:05 ` Marius Vollmer
2005-01-19 0:02 ` Kevin Ryde
2005-02-01 16:02 ` Marius Vollmer
2005-03-02 21:09 ` Marius Vollmer
2005-03-04 0:46 ` Kevin Ryde
2005-03-04 11:33 ` Marius Vollmer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/guile/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=lj3bwyzq9o.fsf@troy.dt.e-technik.uni-dortmund.de \
--to=marius.vollmer@uni-dortmund.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).