guile-devel
[Top][All Lists]
Advanced

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

Re: gc issues


From: Dirk Herrmann
Subject: Re: gc issues
Date: Fri, 15 Sep 2000 03:57:01 +0200 (MEST)

On 14 Sep 2000, Michael Livshin wrote:

> I mean, what's so catastrophic about getting the tag initialized
> before the data?  the code for Guile's primitive types should be
> prepared to find a freecell link (or SCM_EOL) in the data -- well,
> it's not prepared now, but it's doable.  that would leave
> `scm_make_smob' as the only constructor that would need to do locking.
> this is probably OK.

You would also either have to to locking for double cells or clean
them during sweep.  And, there are some types that use double cells, not
just smobs.

However, if memory coherency is not guaranteed, then we'd really need
locking for _every_ fresh cell:  My current assumption was, that every
thread has a set of free cells, which it can obtain even during a
gc.  Only to refill this thread-private pool of cells a lock would be
needed.  A gc running in a different thread would treat all of those free
cells reserved for running threads as being in use.  Thus, the need for
locking would be minimized.

This does not work if memory coherency is not guaranteed:  We may find
that (while a gc is running) a different thread obtains a cell from its
private pool.  Then, the reference to this cell is removed from the
private pool, but it may be that the corresponding reference on the stack
does not become visible in time.  To guarantee that these things are
synchronized, a lock would be needed anyway.

> on the other paw, all through this discussion it is assumed that
> making NEWCELL incur the cost of a function call would be very very
> bad.  but in POSIX-threaded Guile, NEWCELL will have at least to call
> `getspecific' to get the freelist, right?  I wonder if we should stop
> worrying at this point ;).

Yes, and as it seems, threading on multiprocessors forces us to use locks
for cell initialization anyway (except I am missing something).  But, on
the other hand, if we have to use a lock in order to obtain every single
cell, would we still need a thread-private freelist at all?

> Who's afraid of the garbage collector?

I am, and I have always been.  Now you know it.  I feel better now :-)

Best regards
Dirk



reply via email to

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