Patch: replace mutex with object synchronization
Bryce McKinlay
mckinlay@redhat.com
Mon Apr 12 16:39:00 GMT 2004
Anthony Green wrote:
>Since I've been looking at libgcj's use of posix threads I came across
>this bit of code which uses _Jv_Mutex_t to synchronize access to a data
>structure. This is guaranteed to use the underlying system's mutex
>primitives. We can do a little better by using object synchronization
>and our own lightweight locks.
>
>Perhaps this is a micro-optimization, but it also collapses the locking
>code down from three places to a single code fragment.
>
The reason I used the _Jv_Mutex_t here is due to the "low-level" nature
of the class linking code. We need to create an instance of Object in
order to use Java locks, so what happens if we're already in the middle
of linking the Object class? I guess it doesn't matter right now, since
libgcj itself isn't built with the BC-ABI, but eventually, using Java
locks here could potentially lead to circularity problems.
Regards
Bryce
More information about the Java-patches
mailing list