Re: [Sablevm-developer] acquiring monitor
Brought to you by:
egagnon
From: David P. B. <db...@CS...> - 2003-02-10 02:53:46
|
On Sun, Feb 09, 2003 at 02:43:06PM -0800, Archie Cobbs wrote: > David Paul BELANGER wrote: > > In the reflection methods already implemented such as > > nativeGetMethod() (file: java_lang_Class.c), a global monitor is > > acquired. > >=20 > > boolean monitor_acquired =3D JNI_FALSE; > >=20 > > if (_svmf_enter_object_monitor > > (env, > > *(vm->class_loading.boot_loader.classes.virtualmachine-> > > class_instance)) !=3D JNI_OK) > > =20 > > The create/link class methods acquire the same monitor and gc allocat= ed > > function seem to have a global mutex. I don't quite see the reason o= f > > acquiring that monitor. Is it needed for correctness (protecting > > concurrent access to a function I overlooked or create/link/initializ= e > > needs to be done as a block) or is it to avoid > > acquiring/releasing the monitor several times (link_class, > > create_class) i.e. for efficiency as acquiring a lock already own is > > faster? >=20 > As I understand things, the VirtualMachine monitor is used to > protect the internal java type data structures. >=20 > In the case of Class.getMethod() (and therefore Class.nativeGetMethod()= ) > the spec says that accessing the Method object associated with a > class is an "active use" and so the class must be linked if it hasn't > already been linked. And linking the class's type of course requires > acquiring the monitor. >=20 Yes, I do understand that part but the link functions do acquire it. I am wondering why we have this structure: acquire monitor . . . link_class() (inside link_class) acquire monitor . . . release monitor . initialize_class acquire monitor . . release monitor . . release monitor What functions are we protecting with the external acquire monitor? Thanks, David > -Archie >=20 > _______________________________________________________________________= ___ > Archie Cobbs * Packet Design * http://www.packetdesign.= com --=20 --- David B=E9langer Graduate Student School of Computer Science McGill University Office: MC226 Web page: http://www.cs.mcgill.ca/~dbelan2/ Public key: http://www.cs.mcgill.ca/~dbelan2/public_key.txt |