guile-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: C level mutices and condition variables


From: Marius Vollmer
Subject: Re: C level mutices and condition variables
Date: 27 Oct 2002 01:33:31 +0200
User-agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2

Neil Jerram <address@hidden> writes:

> - Why would you want "to have SCM data in a scm_t_mutex"? - isn't the
>   data that you are protecting access to normally a separate variable
>   (or set of variables) from the mutex itself?

I was thinking about data that is needed to implement the mutex
itself.  It would be nice to be able to use SCM values, I'd say, just
because a SCM string as the mutex name is nicer than a C string.

Concretely, I wanted to use SCM lists to implement the waiting queue
(to add fairness to POSIX mutices), mostly because SCM lists are
already there and why shouldn't I use them then?

> - What do you mean by not abstract enough?

You will declare scm_t_mutex variables and thus the size of the
scm_t_mutex structure can not change.  When we want to select mutex
implementations at run-time, that might be a (small) problem.  In any
case, I think it is better to hide mutices behind SCM values, just as
other data structures.

> - In "tell them to use the Scheme level mutices", who is "them", and

The people who use scm_t_mutex etc now.

>   would it be possible for them to use Scheme mutexes from C code, or
>   are you saying that people who need mutexes must code in Scheme?

They can code in C.  Instead of

   scm_t_mutex my_mutex;
   scm_mutex_init (&my_mutex);
   scm_mutex_lock (&my_mutex);

it would be

   SCM my_mutex = scm_make_mutex ();
   scm_lock_mutex (my_mutex);

-- 
GPG: D5D4E405 - 2F9B BCCC 8527 692A 04E3  331E FAF8 226A D5D4 E405




reply via email to

[Prev in Thread] Current Thread [Next in Thread]