Removed the PID niceness surrogate for thread priorities as requested by
authorSebastian Wilhelmi <seppi@seppi.de>
Thu, 26 Feb 2004 14:44:42 +0000 (14:44 +0000)
committerSebastian Wilhelmi <wilhelmi@src.gnome.org>
Thu, 26 Feb 2004 14:44:42 +0000 (14:44 +0000)
2004-02-26  Sebastian Wilhelmi  <seppi@seppi.de>

* 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
ChangeLog.pre-2-10
ChangeLog.pre-2-12
ChangeLog.pre-2-4
ChangeLog.pre-2-6
ChangeLog.pre-2-8
config.h.win32.in
configure.in
docs/reference/ChangeLog
docs/reference/glib/tmpl/threads.sgml
glib/gthread.c

index a6852a369ef2b7f4ebc518bbe62cdba1b2b9258d..67bfd3a2eb1c31346395a04e65e37d92e3772f35 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,9 @@
 2004-02-26  Sebastian Wilhelmi  <seppi@seppi.de>
 
+       * 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.
 
index a6852a369ef2b7f4ebc518bbe62cdba1b2b9258d..67bfd3a2eb1c31346395a04e65e37d92e3772f35 100644 (file)
@@ -1,5 +1,9 @@
 2004-02-26  Sebastian Wilhelmi  <seppi@seppi.de>
 
+       * 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.
 
index a6852a369ef2b7f4ebc518bbe62cdba1b2b9258d..67bfd3a2eb1c31346395a04e65e37d92e3772f35 100644 (file)
@@ -1,5 +1,9 @@
 2004-02-26  Sebastian Wilhelmi  <seppi@seppi.de>
 
+       * 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.
 
index a6852a369ef2b7f4ebc518bbe62cdba1b2b9258d..67bfd3a2eb1c31346395a04e65e37d92e3772f35 100644 (file)
@@ -1,5 +1,9 @@
 2004-02-26  Sebastian Wilhelmi  <seppi@seppi.de>
 
+       * 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.
 
index a6852a369ef2b7f4ebc518bbe62cdba1b2b9258d..67bfd3a2eb1c31346395a04e65e37d92e3772f35 100644 (file)
@@ -1,5 +1,9 @@
 2004-02-26  Sebastian Wilhelmi  <seppi@seppi.de>
 
+       * 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.
 
index a6852a369ef2b7f4ebc518bbe62cdba1b2b9258d..67bfd3a2eb1c31346395a04e65e37d92e3772f35 100644 (file)
@@ -1,5 +1,9 @@
 2004-02-26  Sebastian Wilhelmi  <seppi@seppi.de>
 
+       * 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.
 
index 89a6daa30315605f20a7e47d2073e9fd5c18e9ee..a064a33e3cdc48b1e785d8ac145b9f00748cddfc 100644 (file)
@@ -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
index c47e70406cf0711b44141fd341087e909bd0d21e..2b3d16f5085bd46aae077100943369cbee65cc5a 100644 (file)
@@ -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 <pthread.h> 
-#include <sys/types.h>
-#include <linux/unistd.h>
-#include <unistd.h> 
-_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
index 2583cacf0c9ce266891789c075cffc4a883480cb..5916f002ab90dba86034e11149b671e90dc1ca33 100644 (file)
@@ -1,5 +1,8 @@
 2004-02-26  Sebastian Wilhelmi  <seppi@seppi.de>
 
+        * 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.
index 847ef3ae9469107dd43dbb19a1ffcfb06b474d38..47f9ff02f4153486126e17246066ebf82699579e 100644 (file)
@@ -236,7 +236,7 @@ Specifies the priority of a thread.
 <note>
 <para>
 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.
 <note>
 <para>
 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.
 <note>
 <para>
 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 <structname>GOnce<
 struct.
 </para>
 
-@status: 
-@retval: 
 @Since: 2.4
 
 <!-- ##### ENUM GOnceStatus ##### -->
index 545f4d2badfa2fc9b3b8b7155d6e15930c873029..b136763cf9f2baf2cfc2ae5d96681c067e195ef3 100644 (file)
 
 #include "config.h"
 
-#ifdef G_THREAD_USE_PID_SURROGATE
-#include <sys/types.h>
-#include <sys/time.h>
-#include <sys/resource.h>
-#include <errno.h>
-#include <linux/unistd.h>
-_syscall0(pid_t,gettid)
-#endif /* G_THREAD_USE_PID_SURROGATE */
-
 #ifdef HAVE_UNISTD_H
 #include <unistd.h>
 #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);