From 76c213543aa92511f07dbea5acd85d73a9c57c90 Mon Sep 17 00:00:00 2001 From: Sebastian Wilhelmi Date: Thu, 26 Feb 2004 14:44:42 +0000 Subject: [PATCH] Removed the PID niceness surrogate for thread priorities as requested by 2004-02-26 Sebastian Wilhelmi * configure.in, config.h.win32.in, glib/gthread.c: Removed the PID niceness surrogate for thread priorities as requested by Tim. It does more harm than good. * glib/tmpl/threads.sgml: Updated to reflect removal of the PID niceness surrogate for thread priorities. --- ChangeLog | 4 ++ ChangeLog.pre-2-10 | 4 ++ ChangeLog.pre-2-12 | 4 ++ ChangeLog.pre-2-4 | 4 ++ ChangeLog.pre-2-6 | 4 ++ ChangeLog.pre-2-8 | 4 ++ config.h.win32.in | 3 -- configure.in | 37 ++--------------- docs/reference/ChangeLog | 3 ++ docs/reference/glib/tmpl/threads.sgml | 8 ++-- glib/gthread.c | 58 +-------------------------- 11 files changed, 36 insertions(+), 97 deletions(-) diff --git a/ChangeLog b/ChangeLog index a6852a369..67bfd3a2e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,9 @@ 2004-02-26 Sebastian Wilhelmi + * configure.in, config.h.win32.in, glib/gthread.c: Removed the PID + niceness surrogate for thread priorities as requested by Tim. It + does more harm than good. + * glib/gatomic.c, glib/gatomic.h: New files to implement atomic operations for different platforms. Fixes bug #63621. diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10 index a6852a369..67bfd3a2e 100644 --- a/ChangeLog.pre-2-10 +++ b/ChangeLog.pre-2-10 @@ -1,5 +1,9 @@ 2004-02-26 Sebastian Wilhelmi + * configure.in, config.h.win32.in, glib/gthread.c: Removed the PID + niceness surrogate for thread priorities as requested by Tim. It + does more harm than good. + * glib/gatomic.c, glib/gatomic.h: New files to implement atomic operations for different platforms. Fixes bug #63621. diff --git a/ChangeLog.pre-2-12 b/ChangeLog.pre-2-12 index a6852a369..67bfd3a2e 100644 --- a/ChangeLog.pre-2-12 +++ b/ChangeLog.pre-2-12 @@ -1,5 +1,9 @@ 2004-02-26 Sebastian Wilhelmi + * configure.in, config.h.win32.in, glib/gthread.c: Removed the PID + niceness surrogate for thread priorities as requested by Tim. It + does more harm than good. + * glib/gatomic.c, glib/gatomic.h: New files to implement atomic operations for different platforms. Fixes bug #63621. diff --git a/ChangeLog.pre-2-4 b/ChangeLog.pre-2-4 index a6852a369..67bfd3a2e 100644 --- a/ChangeLog.pre-2-4 +++ b/ChangeLog.pre-2-4 @@ -1,5 +1,9 @@ 2004-02-26 Sebastian Wilhelmi + * configure.in, config.h.win32.in, glib/gthread.c: Removed the PID + niceness surrogate for thread priorities as requested by Tim. It + does more harm than good. + * glib/gatomic.c, glib/gatomic.h: New files to implement atomic operations for different platforms. Fixes bug #63621. diff --git a/ChangeLog.pre-2-6 b/ChangeLog.pre-2-6 index a6852a369..67bfd3a2e 100644 --- a/ChangeLog.pre-2-6 +++ b/ChangeLog.pre-2-6 @@ -1,5 +1,9 @@ 2004-02-26 Sebastian Wilhelmi + * configure.in, config.h.win32.in, glib/gthread.c: Removed the PID + niceness surrogate for thread priorities as requested by Tim. It + does more harm than good. + * glib/gatomic.c, glib/gatomic.h: New files to implement atomic operations for different platforms. Fixes bug #63621. diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8 index a6852a369..67bfd3a2e 100644 --- a/ChangeLog.pre-2-8 +++ b/ChangeLog.pre-2-8 @@ -1,5 +1,9 @@ 2004-02-26 Sebastian Wilhelmi + * configure.in, config.h.win32.in, glib/gthread.c: Removed the PID + niceness surrogate for thread priorities as requested by Tim. It + does more harm than good. + * glib/gatomic.c, glib/gatomic.h: New files to implement atomic operations for different platforms. Fixes bug #63621. diff --git a/config.h.win32.in b/config.h.win32.in index 89a6daa30..a064a33e3 100644 --- a/config.h.win32.in +++ b/config.h.win32.in @@ -72,9 +72,6 @@ /* Source file containing theread implementation */ #define G_THREAD_SOURCE "gthread-win32.c" -/* whether to use the PID niceness surrogate for thread priorities */ -/* #undef G_THREAD_USE_PID_SURROGATE */ - /* A 'va_copy' style function */ #ifndef _MSC_VER #define G_VA_COPY va_copy diff --git a/configure.in b/configure.in index c47e70406..2b3d16f50 100644 --- a/configure.in +++ b/configure.in @@ -1761,35 +1761,6 @@ int main () { fi AC_DEFINE_UNQUOTED(POSIX_YIELD_FUNC,$posix_yield_func,[The POSIX RT yield function]) CPPFLAGS="$glib_save_CPPFLAGS" - - AC_CACHE_CHECK([whether to use the PID niceness surrogate for thread priorities], - glib_cv_use_pid_surrogate, - [AC_TRY_RUN([ -#include -#include -#include -#include -_syscall0(pid_t,gettid) - -pid_t other_pid = 0; - -void* func(void* data) {other_pid = gettid();} -main() -{ pthread_t t; - void *ret; - pthread_create (&t, 0, func, NULL); - pthread_join (t, &ret); - exit (gettid()==other_pid || - $posix_priority_min != $posix_priority_max); -} ], - [glib_cv_use_pid_surrogate=yes], - [glib_cv_use_pid_surrogate=no], - [])]) - GLIB_ASSERT_SET(glib_cv_use_pid_surrogate) - if test "$glib_cv_use_pid_surrogate" = "yes" ; then - AC_DEFINE(G_THREAD_USE_PID_SURROGATE, 1, - [whether to use the PID niceness surrogate for thread priorities]) - fi elif test x"$have_threads" = xwin32; then # It's a pointer to a private struct @@ -1864,11 +1835,11 @@ if test $mutex_has_default = yes ; then LIBS="$glib_save_LIBS" fi -dnl ***************************** -dnl *** GAtomic tests for gcc *** -dnl ***************************** +dnl ******************************** +dnl *** g_atomic_* tests for gcc *** +dnl ******************************** -AC_MSG_CHECKING([whether to use inline assembler routines for atomic integers]) +AC_MSG_CHECKING([whether to use inline assembler code for atomic operations]) if test x"$GCC" = xyes; then case $host_cpu in diff --git a/docs/reference/ChangeLog b/docs/reference/ChangeLog index 2583cacf0..5916f002a 100644 --- a/docs/reference/ChangeLog +++ b/docs/reference/ChangeLog @@ -1,5 +1,8 @@ 2004-02-26 Sebastian Wilhelmi + * glib/tmpl/threads.sgml: Updated to reflect removal of the PID + niceness surrogate for thread priorities. + * glib/glib-overrides.txt, glib/glib-sections.txt, glib/glib-docs.sgml, glib/tmpl/atomic_operations.sgml: Add docs for atomic operations. diff --git a/docs/reference/glib/tmpl/threads.sgml b/docs/reference/glib/tmpl/threads.sgml index 847ef3ae9..47f9ff02f 100644 --- a/docs/reference/glib/tmpl/threads.sgml +++ b/docs/reference/glib/tmpl/threads.sgml @@ -236,7 +236,7 @@ Specifies the priority of a thread. It is not guaranteed, that threads with different priorities really -behave accordingly. On some systems (e.g. Linux) only root can increase +behave accordingly. On some systems (e.g. Linux) there are no thread priorities. On other systems (e.g. Solaris) there doesn't seem to be different scheduling for different priorities. All in all try to avoid being dependent on priorities. @@ -320,7 +320,7 @@ error is set, if and only if the function returns %NULL. It is not guaranteed, that threads with different priorities really -behave accordingly. On some systems (e.g. Linux) only root can increase +behave accordingly. On some systems (e.g. Linux) there are no thread priorities. On other systems (e.g. Solaris) there doesn't seem to be different scheduling for different priorities. All in all try to avoid being dependent on priorities. Use %G_THREAD_PRIORITY_NORMAL here as a @@ -377,7 +377,7 @@ Changes the priority of @thread to @priority. It is not guaranteed, that threads with different priorities really -behave accordingly. On some systems (e.g. Linux) only root can increase +behave accordingly. On some systems (e.g. Linux) there are no thread priorities. On other systems (e.g. Solaris) there doesn't seem to be different scheduling for different priorities. All in all try to avoid being dependent on priorities. @@ -1613,8 +1613,6 @@ Any one-time initialization function must have its own unique GOnce< struct. -@status: -@retval: @Since: 2.4 diff --git a/glib/gthread.c b/glib/gthread.c index 545f4d2ba..b136763cf 100644 --- a/glib/gthread.c +++ b/glib/gthread.c @@ -34,15 +34,6 @@ #include "config.h" -#ifdef G_THREAD_USE_PID_SURROGATE -#include -#include -#include -#include -#include -_syscall0(pid_t,gettid) -#endif /* G_THREAD_USE_PID_SURROGATE */ - #ifdef HAVE_UNISTD_H #include #endif @@ -86,24 +77,8 @@ struct _GRealThread gpointer private_data; gpointer retval; GSystemThread system_thread; -#ifdef G_THREAD_USE_PID_SURROGATE - pid_t tid; -#endif /* G_THREAD_USE_PID_SURROGATE */ }; -#ifdef G_THREAD_USE_PID_SURROGATE -static gint priority_map[4]; -static gboolean prio_warned = FALSE; -# define SET_PRIO(tid, prio) G_STMT_START{ \ - gint error = setpriority (PRIO_PROCESS, (tid), priority_map[prio]); \ - if (error == -1 && errno == EACCES && !prio_warned) \ - { \ - prio_warned = TRUE; \ - g_warning ("Priorities can only be increased by root."); \ - } \ - }G_STMT_END -#endif /* G_THREAD_USE_PID_SURROGATE */ - typedef struct _GStaticPrivateNode GStaticPrivateNode; struct _GStaticPrivateNode { @@ -179,17 +154,6 @@ g_thread_init_glib (void) _g_mem_thread_init (); _g_messages_thread_init (); -#ifdef G_THREAD_USE_PID_SURROGATE - priority_map[G_THREAD_PRIORITY_NORMAL] = - getpriority (PRIO_PROCESS, (gettid ())); - 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 */ - g_threads_got_initialized = TRUE; g_thread_specific_private = g_private_new (g_thread_cleanup); @@ -583,10 +547,6 @@ g_thread_create_proxy (gpointer data) g_assert (data); -#ifdef G_THREAD_USE_PID_SURROGATE - thread->tid = gettid (); -#endif /* G_THREAD_USE_PID_SURROGATE */ - /* This has to happen before G_LOCK, as that might call g_thread_self */ g_private_set (g_thread_specific_private, data); @@ -595,11 +555,6 @@ g_thread_create_proxy (gpointer data) G_LOCK (g_thread); G_UNLOCK (g_thread); -#ifdef G_THREAD_USE_PID_SURROGATE - if (g_thread_use_default_impl) - SET_PRIO (thread->tid, thread->thread.priority); -#endif /* G_THREAD_USE_PID_SURROGATE */ - thread->retval = thread->thread.func (thread->thread.data); return NULL; @@ -697,13 +652,8 @@ g_thread_set_priority (GThread* thread, thread->priority = priority; -#ifdef G_THREAD_USE_PID_SURROGATE - if (g_thread_use_default_impl) - SET_PRIO (real->tid, priority); - else -#endif /* G_THREAD_USE_PID_SURROGATE */ - G_THREAD_CF (thread_set_priority, (void)0, - (&real->system_thread, priority)); + G_THREAD_CF (thread_set_priority, (void)0, + (&real->system_thread, priority)); } GThread* @@ -727,10 +677,6 @@ g_thread_self (void) if (g_thread_supported ()) G_THREAD_UF (thread_self, (&thread->system_thread)); -#ifdef G_THREAD_USE_PID_SURROGATE - thread->tid = gettid (); -#endif /* G_THREAD_USE_PID_SURROGATE */ - g_private_set (g_thread_specific_private, thread); G_LOCK (g_thread);