Han-Wen Nienhuys escreveu: >>> The use of scm_gc_mark() outside of GC is fundamentally broken, since it >>> creates race conditions in the presence of threads. >> I was not aware that this was the case. >> >> My impression was that the mark phase is global; it requires all threads >> that were in guile mode to go dormant, and those that were not in guile >> mode cannot enter guile mode until the mark is complete. > > Yes, the mark phase is global, but the thread locking is done in > scm_i_gc; once the marking starts, there is only one thread. Since > scm_gc_mark is called from the smob mark functions, it does not force > other threads to go dormant. It could, but I suspect the lock would > be a contention point.
It would be very cool to have thread safe marking for a different reason: marking it is the expensive step in GC, so if we can do that in N threads concurrently (on a SMP machine) we have can speed it up by almost a factor N. To do it properly, you could do the bitvector marking with a compare & swap instruction. -- Han-Wen Nienhuys - [EMAIL PROTECTED] - http://www.xs4all.nl/~hanwen