LCOV - code coverage report
Current view: top level - threads - lock.hpp (source / functions) Hit Total Coverage
Test: coverage.info Lines: 1 1 100.0 %
Date: 2017-07-14 10:03:36 Functions: 1 3 33.3 %

          Line data    Source code
       1             : /* src/threads/lock.hpp - lock implementation
       2             : 
       3             :    Copyright (C) 1996-2013
       4             :    CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
       5             : 
       6             :    This file is part of CACAO.
       7             : 
       8             :    This program is free software; you can redistribute it and/or
       9             :    modify it under the terms of the GNU General Public License as
      10             :    published by the Free Software Foundation; either version 2, or (at
      11             :    your option) any later version.
      12             : 
      13             :    This program is distributed in the hope that it will be useful, but
      14             :    WITHOUT ANY WARRANTY; without even the implied warranty of
      15             :    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
      16             :    General Public License for more details.
      17             : 
      18             :    You should have received a copy of the GNU General Public License
      19             :    along with this program; if not, write to the Free Software
      20             :    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
      21             :    02110-1301, USA.
      22             : 
      23             : */
      24             : 
      25             : 
      26             : #ifndef LOCK_HPP_
      27             : #define LOCK_HPP_ 1
      28             : 
      29             : #include "native/llni.hpp"
      30             : 
      31             : #include "threads/mutex.hpp"
      32             : 
      33             : #include "vm/global.hpp"
      34             : 
      35       20333 : template <class T> class List;
      36             : 
      37             : /* typedefs *******************************************************************/
      38             : 
      39             : typedef struct lock_record_t    lock_record_t;
      40             : typedef struct lock_hashtable_t lock_hashtable_t;
      41             : 
      42             : 
      43             : /* lock_record_t ***************************************************************
      44             : 
      45             :    Lock record struct representing an inflated ("fat") lock.
      46             : 
      47             : *******************************************************************************/
      48             : 
      49             : struct lock_record_t {
      50             :         java_object_t       *object;             /* object for which this lock is */
      51             :         struct threadobject *owner;              /* current owner of this monitor */
      52             :         s4                   count;              /* recursive lock count          */
      53             :         Mutex*               mutex;              /* mutex for synchronizing       */
      54             :         List<threadobject*>* waiters;            /* list of threads waiting       */
      55             :         lock_record_t       *hashlink;           /* next record in hash chain     */
      56             : };
      57             : 
      58             : 
      59             : /* lock_hashtable_t ************************************************************
      60             :  
      61             :    The global hashtable mapping objects to lock records.
      62             : 
      63             : *******************************************************************************/
      64             : 
      65             : struct lock_hashtable_t {
      66             :     Mutex*               mutex;       /* mutex for synch. access to the table */
      67             :         u4                   size;        /* number of slots                      */
      68             :         u4                   entries;     /* current number of entries            */
      69             :         lock_record_t      **ptr;         /* the table of slots, uses ext. chain. */
      70             : };
      71             : 
      72             : 
      73             : /* functions ******************************************************************/
      74             : 
      75             : void lock_init(void);
      76             : 
      77             : bool lock_monitor_enter(java_handle_t *);
      78             : bool lock_monitor_exit(java_handle_t *);
      79             : 
      80             : bool lock_is_held_by_current_thread(java_handle_t *o);
      81             : 
      82             : void lock_wait_for_object(java_handle_t *o, s8 millis, s4 nanos);
      83             : void lock_notify_object(java_handle_t *o);
      84             : void lock_notify_all_object(java_handle_t *o);
      85             : 
      86             : #if defined(ENABLE_GC_BOEHM)
      87             : void lock_schedule_lockrecord_removal(java_handle_t *o);
      88             : #endif
      89             : 
      90             : 
      91             : /* defines ********************************************************************/
      92             : 
      93             : #define LOCK_MONITOR_ENTER(o)    lock_monitor_enter((java_handle_t *) LLNI_QUICKWRAP(o))
      94             : #define LOCK_MONITOR_EXIT(o)     lock_monitor_exit((java_handle_t *) LLNI_QUICKWRAP(o))
      95             : 
      96             : #endif // LOCK_HPP_
      97             : 
      98             : 
      99             : /*
     100             :  * These are local overrides for various environment variables in Emacs.
     101             :  * Please do not remove this and leave it at the end of the file, where
     102             :  * Emacs will automagically detect them.
     103             :  * ---------------------------------------------------------------------
     104             :  * Local variables:
     105             :  * mode: c++
     106             :  * indent-tabs-mode: t
     107             :  * c-basic-offset: 4
     108             :  * tab-width: 4
     109             :  * End:
     110             :  * vim:noexpandtab:sw=4:ts=4:
     111             :  */

Generated by: LCOV version 1.11