[utils] Explicitly check if the system has mincore instead of relying on mmap been...
[mono-project.git] / mono / metadata / monitor.h
blob4d2bcdc93922a6942a495704856f65774cb20440
1 /*
2 * monitor.h: Monitor locking functions
4 * Author:
5 * Dick Porter (dick@ximian.com)
7 * (C) 2003 Ximian, Inc
8 */
10 #ifndef _MONO_METADATA_MONITOR_H_
11 #define _MONO_METADATA_MONITOR_H_
13 #include <glib.h>
14 #include <mono/metadata/object.h>
15 #include <mono/io-layer/io-layer.h>
16 #include "mono/utils/mono-compiler.h"
18 G_BEGIN_DECLS
20 #define OWNER_MASK 0x0000ffff
21 #define ENTRY_COUNT_MASK 0xffff0000
22 #define ENTRY_COUNT_WAITERS 0x80000000
23 #define ENTRY_COUNT_ZERO 0x7fff0000
24 #define ENTRY_COUNT_SHIFT 16
26 struct _MonoThreadsSync
29 * The entry count field can be negative, which would mean that the entry_sem is
30 * signaled and nobody is waiting to acquire it. This can happen when the thread
31 * that was waiting is either interrupted or timeouts, and the owner releases
32 * the lock before the forementioned thread updates the entry count.
34 * The 0 entry_count value is encoded as ENTRY_COUNT_ZERO, positive numbers being
35 * greater than it and negative numbers smaller than it.
37 guint32 status; /* entry_count (16) | owner_id (16) */
38 guint32 nest;
39 #ifdef HAVE_MOVING_COLLECTOR
40 gint32 hash_code;
41 #endif
42 HANDLE entry_sem;
43 GSList *wait_list;
44 void *data;
48 MONO_API void mono_locks_dump (gboolean include_untaken);
50 void mono_monitor_init (void) MONO_INTERNAL;
51 void mono_monitor_cleanup (void) MONO_INTERNAL;
53 void** mono_monitor_get_object_monitor_weak_link (MonoObject *object) MONO_INTERNAL;
55 void mono_monitor_threads_sync_members_offset (int *status_offset, int *nest_offset) MONO_INTERNAL;
56 #define MONO_THREADS_SYNC_MEMBER_OFFSET(o) ((o)>>8)
57 #define MONO_THREADS_SYNC_MEMBER_SIZE(o) ((o)&0xff)
59 extern gboolean ves_icall_System_Threading_Monitor_Monitor_try_enter(MonoObject *obj, guint32 ms) MONO_INTERNAL;
60 extern gboolean ves_icall_System_Threading_Monitor_Monitor_test_owner(MonoObject *obj) MONO_INTERNAL;
61 extern gboolean ves_icall_System_Threading_Monitor_Monitor_test_synchronised(MonoObject *obj) MONO_INTERNAL;
62 extern void ves_icall_System_Threading_Monitor_Monitor_pulse(MonoObject *obj) MONO_INTERNAL;
63 extern void ves_icall_System_Threading_Monitor_Monitor_pulse_all(MonoObject *obj) MONO_INTERNAL;
64 extern gboolean ves_icall_System_Threading_Monitor_Monitor_wait(MonoObject *obj, guint32 ms) MONO_INTERNAL;
65 extern void ves_icall_System_Threading_Monitor_Monitor_try_enter_with_atomic_var (MonoObject *obj, guint32 ms, char *lockTaken) MONO_INTERNAL;
67 G_END_DECLS
69 #endif /* _MONO_METADATA_MONITOR_H_ */