#include <pthread.h>
#include <sched.h>
+#include <sysdep/locks.h>
//
// Typedefs.
mu->owner = 0;
}
-inline int
-_Jv_MutexLock (_Jv_Mutex_t *mu)
-{
- pthread_t self = pthread_self ();
- if (mu->owner == self)
- {
- mu->count++;
- }
- else
- {
-# ifdef LOCK_DEBUG
- int result = pthread_mutex_lock (&mu->mutex);
- if (0 != result)
- {
- fprintf(stderr, "Pthread_mutex_lock returned %d\n", result);
- for (;;) {}
- }
-# else
- pthread_mutex_lock (&mu->mutex);
-# endif
- mu->count = 1;
- mu->owner = self;
- }
- return 0;
-}
+extern int _Jv_MutexLock (_Jv_Mutex_t *);
inline int
_Jv_MutexUnlock (_Jv_Mutex_t *mu)
void _Jv_ThreadInterrupt (_Jv_Thread_t *data);
+// park() / unpark() support
+
+struct ParkHelper
+{
+ volatile obj_addr_t permit;
+ pthread_mutex_t mutex;
+ pthread_cond_t cond;
+
+ void init ();
+ void deactivate ();
+ void destroy ();
+ void park (jboolean isAbsolute, jlong time);
+ void unpark ();
+};
+
+inline void
+ParkHelper::init ()
+{
+ pthread_mutex_init (&mutex, NULL);
+ pthread_cond_init (&cond, NULL);
+}
+
+inline void
+ParkHelper::destroy ()
+{
+ pthread_mutex_destroy (&mutex);
+ pthread_cond_destroy (&cond);
+}
+
#endif /* __JV_POSIX_THREADS__ */