+2002-08-06 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
+
+ * glib/gthread.c: Set the normal PID surrogate priority according
+ to getpid() to avoid errors for niced processes. (#86116)
+
+ * gthread/gthread-impl.c, gthread/gthread-posix.c,
+ gthread/gthread-solaris.c: Do the same for the posix/dce
+ implementation. Solaris still needs to set priority of the main
+ thread, because all unbound threads will schedule according to
+ that value and it defaults to 0 (the minimal value).
+
Thu Jul 25 14:23:15 2002 Owen Taylor <otaylor@redhat.com>
* glib/gfileutils.c: Clarify the behavior of g_build_path()
+2002-08-06 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
+
+ * glib/gthread.c: Set the normal PID surrogate priority according
+ to getpid() to avoid errors for niced processes. (#86116)
+
+ * gthread/gthread-impl.c, gthread/gthread-posix.c,
+ gthread/gthread-solaris.c: Do the same for the posix/dce
+ implementation. Solaris still needs to set priority of the main
+ thread, because all unbound threads will schedule according to
+ that value and it defaults to 0 (the minimal value).
+
Thu Jul 25 14:23:15 2002 Owen Taylor <otaylor@redhat.com>
* glib/gfileutils.c: Clarify the behavior of g_build_path()
+2002-08-06 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
+
+ * glib/gthread.c: Set the normal PID surrogate priority according
+ to getpid() to avoid errors for niced processes. (#86116)
+
+ * gthread/gthread-impl.c, gthread/gthread-posix.c,
+ gthread/gthread-solaris.c: Do the same for the posix/dce
+ implementation. Solaris still needs to set priority of the main
+ thread, because all unbound threads will schedule according to
+ that value and it defaults to 0 (the minimal value).
+
Thu Jul 25 14:23:15 2002 Owen Taylor <otaylor@redhat.com>
* glib/gfileutils.c: Clarify the behavior of g_build_path()
+2002-08-06 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
+
+ * glib/gthread.c: Set the normal PID surrogate priority according
+ to getpid() to avoid errors for niced processes. (#86116)
+
+ * gthread/gthread-impl.c, gthread/gthread-posix.c,
+ gthread/gthread-solaris.c: Do the same for the posix/dce
+ implementation. Solaris still needs to set priority of the main
+ thread, because all unbound threads will schedule according to
+ that value and it defaults to 0 (the minimal value).
+
Thu Jul 25 14:23:15 2002 Owen Taylor <otaylor@redhat.com>
* glib/gfileutils.c: Clarify the behavior of g_build_path()
+2002-08-06 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
+
+ * glib/gthread.c: Set the normal PID surrogate priority according
+ to getpid() to avoid errors for niced processes. (#86116)
+
+ * gthread/gthread-impl.c, gthread/gthread-posix.c,
+ gthread/gthread-solaris.c: Do the same for the posix/dce
+ implementation. Solaris still needs to set priority of the main
+ thread, because all unbound threads will schedule according to
+ that value and it defaults to 0 (the minimal value).
+
Thu Jul 25 14:23:15 2002 Owen Taylor <otaylor@redhat.com>
* glib/gfileutils.c: Clarify the behavior of g_build_path()
+2002-08-06 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
+
+ * glib/gthread.c: Set the normal PID surrogate priority according
+ to getpid() to avoid errors for niced processes. (#86116)
+
+ * gthread/gthread-impl.c, gthread/gthread-posix.c,
+ gthread/gthread-solaris.c: Do the same for the posix/dce
+ implementation. Solaris still needs to set priority of the main
+ thread, because all unbound threads will schedule according to
+ that value and it defaults to 0 (the minimal value).
+
Thu Jul 25 14:23:15 2002 Owen Taylor <otaylor@redhat.com>
* glib/gfileutils.c: Clarify the behavior of g_build_path()
+2002-08-06 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
+
+ * glib/gthread.c: Set the normal PID surrogate priority according
+ to getpid() to avoid errors for niced processes. (#86116)
+
+ * gthread/gthread-impl.c, gthread/gthread-posix.c,
+ gthread/gthread-solaris.c: Do the same for the posix/dce
+ implementation. Solaris still needs to set priority of the main
+ thread, because all unbound threads will schedule according to
+ that value and it defaults to 0 (the minimal value).
+
Thu Jul 25 14:23:15 2002 Owen Taylor <otaylor@redhat.com>
* glib/gfileutils.c: Clarify the behavior of g_build_path()
};
#ifdef G_THREAD_USE_PID_SURROGATE
-static gint priority_map[] = { 15, 0, -15, -20 };
+static gint priority_map[4];
static gboolean prio_warned = FALSE;
# define SET_PRIO(pid, prio) G_STMT_START{ \
gint error = setpriority (PRIO_PROCESS, (pid), priority_map[prio]); \
G_THREAD_UF (thread_self, (&main_thread->system_thread));
g_mutex_protect_static_mutex_allocation = g_mutex_new ();
+
+#ifdef G_THREAD_USE_PID_SURROGATE
+ priority_map[G_THREAD_PRIORITY_NORMAL] =
+ getpriority (PRIO_PROCESS, (getpid ()));
+ priority_map[G_THREAD_PRIORITY_LOW] =
+ MIN (20, priority_map[G_THREAD_PRIORITY_NORMAL] + 10);
+ priority_map[G_THREAD_PRIORITY_HIGH] =
+ MAX (-20, priority_map[G_THREAD_PRIORITY_NORMAL] - 10);
+ priority_map[G_THREAD_PRIORITY_URGENT] =
+ MAX (-20, priority_map[G_THREAD_PRIORITY_NORMAL] - 15);
+#endif /* G_THREAD_USE_PID_SURROGATE */
}
void
#endif
#ifndef PRIORITY_NORMAL_VALUE
-# define PRIORITY_NORMAL_VALUE \
- (PRIORITY_LOW_VALUE + (PRIORITY_URGENT_VALUE - PRIORITY_LOW_VALUE) * 4 / 10)
+# define PRIORITY_NORMAL_VALUE \
+ ((PRIORITY_LOW_VALUE * 6 + PRIORITY_URGENT_VALUE * 4) / 10)
#endif /* PRIORITY_NORMAL_VALUE */
#ifndef PRIORITY_HIGH_VALUE
-# define PRIORITY_HIGH_VALUE \
- (PRIORITY_LOW_VALUE + (PRIORITY_URGENT_VALUE - PRIORITY_LOW_VALUE) * 8 / 10)
+# define PRIORITY_HIGH_VALUE \
+ ((PRIORITY_NORMAL_VALUE + PRIORITY_URGENT_VALUE * 2) / 3)
#endif /* PRIORITY_HIGH_VALUE */
void g_mutex_init (void);
* all the thread functions
*/
g_threads_got_initialized = TRUE;
-
- /* we want the main thread to run with normal priority */
- g_thread_set_priority (g_thread_self(), G_THREAD_PRIORITY_NORMAL);
}
#else /* !G_THREADS_ENABLED */
#if defined (POSIX_MIN_PRIORITY) && defined (POSIX_MAX_PRIORITY)
# define HAVE_PRIORITIES 1
+static gint priority_normal_value;
# ifdef __FreeBSD__
/* FreeBSD threads use different priority values from the POSIX_
* defines so we just set them here. The corresponding macros
# define PRIORITY_LOW_VALUE 0
# define PRIORITY_URGENT_VALUE 31
# else /* !__FreeBSD__ */
-# define PRIORITY_LOW_VALUE POSIX_MIN_PRIORITY
-# define PRIORITY_URGENT_VALUE POSIX_MAX_PRIORITY
+# define PRIORITY_LOW_VALUE POSIX_MIN_PRIORITY
+# define PRIORITY_URGENT_VALUE POSIX_MAX_PRIORITY
# endif /* !__FreeBSD__ */
+# define PRIORITY_NORMAL_VALUE priority_normal_value
#endif /* POSIX_MIN_PRIORITY && POSIX_MAX_PRIORITY */
static gulong g_thread_min_stack_size = 0;
#define G_MUTEX_SIZE (sizeof (pthread_mutex_t))
-#ifdef _SC_THREAD_STACK_MIN
+#if defined(_SC_THREAD_STACK_MIN) || defined (HAVE_PRIORITIES)
#define HAVE_G_THREAD_IMPL_INIT
static void
g_thread_impl_init()
{
+#ifdef _SC_THREAD_STACK_MIN
g_thread_min_stack_size = MAX (sysconf (_SC_THREAD_STACK_MIN), 0);
-}
#endif /* _SC_THREAD_STACK_MIN */
+#ifdef HAVE_PRIORITIES
+# ifdef G_THREADS_IMPL_POSIX
+ {
+ struct sched_param sched;
+ int policy;
+ posix_check_cmd (pthread_getschedparam (pthread_self(), &policy, &sched));
+ priority_normal_value = sched.sched_priority;
+ }
+# else /* G_THREADS_IMPL_DCE */
+ posix_check_cmd (priority_normal_value =
+ pthread_getprio (*(pthread_t*)thread,
+ g_thread_priority_map [priority]));
+# endif
+#endif /* HAVE_PRIORITIES */
+
+}
+#endif /* _SC_THREAD_STACK_MIN || HAVE_PRIORITIES */
static GMutex *
g_mutex_new_posix_impl (void)
#define G_MUTEX_SIZE (sizeof (mutex_t))
#define PRIORITY_LOW_VALUE 0
+#define PRIORITY_NORMAL_VALUE 50
#define PRIORITY_URGENT_VALUE 127
#define HAVE_G_THREAD_IMPL_INIT
g_thread_impl_init()
{
g_thread_min_stack_size = thr_min_stack();
+ /* The default priority on Solaris is 0. Set it to something sane */
+ solaris_check_for_error (thr_setprio (thr_self (), PRIORITY_NORMAL_VALUE));
}
static GMutex *