X-Git-Url: http://git.sourceforge.jp/view?a=blobdiff_plain;f=libjava%2Fposix-threads.cc;h=91da25cf38de9d9fe49557993aa7a30b33b941f5;hb=7bb1225a6a31c86f74dfd7284e10d8bac72e17cb;hp=e92348bcc2cc078bdb768e9ba23c1c6c7ccda1b5;hpb=d30cece008b62a32c342597ac2f1c074c1d510f1;p=pf3gnuchains%2Fgcc-fork.git diff --git a/libjava/posix-threads.cc b/libjava/posix-threads.cc index e92348bcc2c..91da25cf38d 100644 --- a/libjava/posix-threads.cc +++ b/libjava/posix-threads.cc @@ -1,6 +1,6 @@ // posix-threads.cc - interface between libjava and POSIX threads. -/* Copyright (C) 1998, 1999, 2000, 2001 Free Software Foundation +/* Copyright (C) 1998, 1999, 2000, 2001, 2004 Free Software Foundation This file is part of libgcj. @@ -24,6 +24,9 @@ details. */ #include #include #include +#ifdef HAVE_UNISTD_H +#include // To test for _POSIX_THREAD_PRIORITY_SCHEDULING +#endif #include #include @@ -31,6 +34,7 @@ details. */ #include #include #include +#include // This is used to implement thread startup. struct starter @@ -190,7 +194,7 @@ _Jv_CondWait (_Jv_ConditionVariable_t *cv, _Jv_Mutex_t *mu, int _Jv_CondNotify (_Jv_ConditionVariable_t *cv, _Jv_Mutex_t *mu) { - if (_Jv_PthreadCheckMonitor (mu)) + if (_Jv_MutexCheckMonitor (mu)) return _JV_NOT_OWNER; _Jv_Thread_t *target; @@ -229,7 +233,7 @@ _Jv_CondNotify (_Jv_ConditionVariable_t *cv, _Jv_Mutex_t *mu) int _Jv_CondNotifyAll (_Jv_ConditionVariable_t *cv, _Jv_Mutex_t *mu) { - if (_Jv_PthreadCheckMonitor (mu)) + if (_Jv_MutexCheckMonitor (mu)) return _JV_NOT_OWNER; _Jv_Thread_t *target; @@ -277,6 +281,17 @@ handle_intr (int) // Do nothing. } +static void +block_sigchld() +{ + sigset_t mask; + sigemptyset (&mask); + sigaddset (&mask, SIGCHLD); + int c = pthread_sigmask (SIG_BLOCK, &mask, NULL); + if (c != 0) + JvFail (strerror (c)); +} + void _Jv_InitThreads (void) { @@ -292,6 +307,10 @@ _Jv_InitThreads (void) sigemptyset (&act.sa_mask); act.sa_flags = 0; sigaction (INTR, &act, NULL); + + // Block SIGCHLD here to ensure that any non-Java threads inherit the new + // signal mask. + block_sigchld(); } _Jv_Thread_t * @@ -318,6 +337,7 @@ _Jv_ThreadDestroyData (_Jv_Thread_t *data) void _Jv_ThreadSetPriority (_Jv_Thread_t *data, jint prio) { +#ifdef _POSIX_THREAD_PRIORITY_SCHEDULING if (data->flags & FLAG_START) { struct sched_param param; @@ -325,6 +345,7 @@ _Jv_ThreadSetPriority (_Jv_Thread_t *data, jint prio) param.sched_priority = prio; pthread_setschedparam (data->thread, SCHED_RR, ¶m); } +#endif } void @@ -353,6 +374,8 @@ _Jv_ThreadRegister (_Jv_Thread_t *data) _Jv_self_cache[current_index].high_sp_bits = BAD_HIGH_SP_VALUE; } # endif + // Block SIGCHLD which is used in natPosixProcess.cc. + block_sigchld(); } void @@ -398,6 +421,10 @@ _Jv_ThreadStart (java::lang::Thread *thread, _Jv_Thread_t *data, return; data->flags |= FLAG_START; + // Block SIGCHLD which is used in natPosixProcess.cc. + // The current mask is inherited by the child thread. + block_sigchld(); + param.sched_priority = thread->getPriority(); pthread_attr_init (&attr);