1 /* src/threads/native/lock.h - lock implementation
3 Copyright (C) 1996-2005, 2006, 2007 R. Grafl, A. Krall, C. Kruegel,
4 C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring,
5 E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich,
6 J. Wenninger, Institut f. Computersprachen - TU Wien
8 This file is part of CACAO.
10 This program is free software; you can redistribute it and/or
11 modify it under the terms of the GNU General Public License as
12 published by the Free Software Foundation; either version 2, or (at
13 your option) any later version.
15 This program is distributed in the hope that it will be useful, but
16 WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 General Public License for more details.
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software
22 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
37 #include "vm/global.h"
41 /* typedefs *******************************************************************/
43 typedef struct lock_record_t lock_record_t;
44 typedef struct lock_waiter_t lock_waiter_t;
45 typedef struct lock_hashtable_t lock_hashtable_t;
48 /* lock_waiter_t ***************************************************************
50 List node for storing a waiting thread.
52 *******************************************************************************/
54 struct lock_waiter_t {
55 struct threadobject *waiter; /* the waiting thread */
56 lock_waiter_t *next; /* next in list */
60 /* lock_record_t ***************************************************************
62 Lock record struct representing an inflated ("fat") lock.
64 *******************************************************************************/
66 struct lock_record_t {
67 java_object_t *object; /* object for which this lock is */
68 struct threadobject *owner; /* current owner of this monitor */
69 s4 count; /* recursive lock count */
70 pthread_mutex_t mutex; /* mutex for synchronizing */
71 lock_waiter_t *waiters; /* list of threads waiting */
72 lock_record_t *hashlink; /* next record in hash chain */
76 /* lock_hashtable_t ************************************************************
78 The global hashtable mapping objects to lock records.
80 *******************************************************************************/
82 struct lock_hashtable_t {
83 pthread_mutex_t mutex; /* mutex for synch. access to the table */
84 u4 size; /* number of slots */
85 u4 entries; /* current number of entries */
86 lock_record_t **ptr; /* the table of slots, uses ext. chain. */
90 /* defines ********************************************************************/
92 #define LOCK_INIT_OBJECT_LOCK(o) lock_init_object_lock((java_object_t *) (o))
94 #define LOCK_MONITOR_ENTER(o) lock_monitor_enter((java_object_t *) (o))
95 #define LOCK_MONITOR_EXIT(o) lock_monitor_exit((java_object_t *) (o))
101 * These are local overrides for various environment variables in Emacs.
102 * Please do not remove this and leave it at the end of the file, where
103 * Emacs will automagically detect them.
104 * ---------------------------------------------------------------------
107 * indent-tabs-mode: t
111 * vim:noexpandtab:sw=4:ts=4: