#include <pthread.h>
#include <sched.h>
+#include <sysdep/locks.h>
//
// Typedefs.
}
//
+// Signal helpers.
+//
+
+void _Jv_BlockSigchld();
+void _Jv_UnBlockSigchld();
+
+
+//
// Condition variables.
//
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);
-// Increases a thread's suspend count. If the thread's previous
-// suspend count was zero, i.e., it is not suspended, this function
-// will suspend the thread. This function may be used to suspend
-// any thread from any other thread (or suspend itself).
-void _Jv_ThreadDebugSuspend (_Jv_Thread_t *data);
+// park() / unpark() support
-// Decreases a thread's suspend count. If the thread's new thread
-// count is zero, the thread is resumed. This function may be used
-// by any thread to resume any other thread.
-void _Jv_ThreadDebugResume (_Jv_Thread_t *data);
+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 ();
+};
-// Get the suspend count for a thread
-jint _Jv_ThreadDebugSuspendCount (_Jv_Thread_t *data);
+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__ */