For the PID thread priorities surrogate use gettid instead of getpid. This
authorSebastian Wilhelmi <seppi@seppi.de>
Wed, 25 Feb 2004 13:23:14 +0000 (13:23 +0000)
committerSebastian Wilhelmi <wilhelmi@src.gnome.org>
Wed, 25 Feb 2004 13:23:14 +0000 (13:23 +0000)
2004-02-25  Sebastian Wilhelmi  <seppi@seppi.de>

* configure.in, glib/gthread.c: For the PID thread priorities
surrogate use gettid instead of getpid. This also works with nptl
(on linux-2.6), as well as with linuxthreads (on linux-2.4).

ChangeLog
ChangeLog.pre-2-10
ChangeLog.pre-2-12
ChangeLog.pre-2-4
ChangeLog.pre-2-6
ChangeLog.pre-2-8
configure.in
glib/gthread.c

index dcebdf3..1cc7578 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2004-02-25  Sebastian Wilhelmi  <seppi@seppi.de>
+
+       * configure.in, glib/gthread.c: For the PID thread priorities
+       surrogate use gettid instead of getpid. This also works with nptl
+       (on linux-2.6), as well as with linuxthreads (on linux-2.4).
+
 2004-02-24  Sebastian Wilhelmi  <seppi@seppi.de>
 
        * glib/grand.c: Add Since: 2.4, where due
index dcebdf3..1cc7578 100644 (file)
@@ -1,3 +1,9 @@
+2004-02-25  Sebastian Wilhelmi  <seppi@seppi.de>
+
+       * configure.in, glib/gthread.c: For the PID thread priorities
+       surrogate use gettid instead of getpid. This also works with nptl
+       (on linux-2.6), as well as with linuxthreads (on linux-2.4).
+
 2004-02-24  Sebastian Wilhelmi  <seppi@seppi.de>
 
        * glib/grand.c: Add Since: 2.4, where due
index dcebdf3..1cc7578 100644 (file)
@@ -1,3 +1,9 @@
+2004-02-25  Sebastian Wilhelmi  <seppi@seppi.de>
+
+       * configure.in, glib/gthread.c: For the PID thread priorities
+       surrogate use gettid instead of getpid. This also works with nptl
+       (on linux-2.6), as well as with linuxthreads (on linux-2.4).
+
 2004-02-24  Sebastian Wilhelmi  <seppi@seppi.de>
 
        * glib/grand.c: Add Since: 2.4, where due
index dcebdf3..1cc7578 100644 (file)
@@ -1,3 +1,9 @@
+2004-02-25  Sebastian Wilhelmi  <seppi@seppi.de>
+
+       * configure.in, glib/gthread.c: For the PID thread priorities
+       surrogate use gettid instead of getpid. This also works with nptl
+       (on linux-2.6), as well as with linuxthreads (on linux-2.4).
+
 2004-02-24  Sebastian Wilhelmi  <seppi@seppi.de>
 
        * glib/grand.c: Add Since: 2.4, where due
index dcebdf3..1cc7578 100644 (file)
@@ -1,3 +1,9 @@
+2004-02-25  Sebastian Wilhelmi  <seppi@seppi.de>
+
+       * configure.in, glib/gthread.c: For the PID thread priorities
+       surrogate use gettid instead of getpid. This also works with nptl
+       (on linux-2.6), as well as with linuxthreads (on linux-2.4).
+
 2004-02-24  Sebastian Wilhelmi  <seppi@seppi.de>
 
        * glib/grand.c: Add Since: 2.4, where due
index dcebdf3..1cc7578 100644 (file)
@@ -1,3 +1,9 @@
+2004-02-25  Sebastian Wilhelmi  <seppi@seppi.de>
+
+       * configure.in, glib/gthread.c: For the PID thread priorities
+       surrogate use gettid instead of getpid. This also works with nptl
+       (on linux-2.6), as well as with linuxthreads (on linux-2.4).
+
 2004-02-24  Sebastian Wilhelmi  <seppi@seppi.de>
 
        * glib/grand.c: Add Since: 2.4, where due
index f318b12..fc16232 100644 (file)
@@ -1767,16 +1767,19 @@ int main () {
                  [AC_TRY_RUN([
 #include <pthread.h> 
 #include <sys/types.h>
-#include <unistd.h>
+#include <linux/unistd.h>
+#include <unistd.h> 
+_syscall0(pid_t,gettid)
+
 pid_t other_pid = 0;
 
-void* func(void* data) {other_pid = getpid();}
+void* func(void* data) {other_pid = gettid();}
 main()
 { pthread_t t; 
   void *ret;
   pthread_create (&t, 0, func, NULL);
   pthread_join (t, &ret);
-  exit (getpid()==other_pid || 
+  exit (gettid()==other_pid || 
        $posix_priority_min != $posix_priority_max);
 }               ],
                [glib_cv_use_pid_surrogate=yes],
index 138bc32..545f4d2 100644 (file)
@@ -39,6 +39,8 @@
 #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
@@ -85,15 +87,15 @@ struct  _GRealThread
   gpointer retval;
   GSystemThread system_thread;
 #ifdef G_THREAD_USE_PID_SURROGATE
-  pid_t pid;
+  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(pid, prio) G_STMT_START{                             \
-  gint error = setpriority (PRIO_PROCESS, (pid), priority_map[prio]);  \
+# 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;                                              \
@@ -179,7 +181,7 @@ g_thread_init_glib (void)
   
 #ifdef G_THREAD_USE_PID_SURROGATE
   priority_map[G_THREAD_PRIORITY_NORMAL] = 
-    getpriority (PRIO_PROCESS, (getpid ()));
+    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] = 
@@ -582,7 +584,7 @@ g_thread_create_proxy (gpointer data)
   g_assert (data);
 
 #ifdef G_THREAD_USE_PID_SURROGATE
-  thread->pid = getpid ();
+  thread->tid = gettid ();
 #endif /* G_THREAD_USE_PID_SURROGATE */
 
   /* This has to happen before G_LOCK, as that might call g_thread_self */
@@ -595,7 +597,7 @@ g_thread_create_proxy (gpointer data)
  
 #ifdef G_THREAD_USE_PID_SURROGATE
   if (g_thread_use_default_impl)
-    SET_PRIO (thread->pid, thread->thread.priority);
+    SET_PRIO (thread->tid, thread->thread.priority);
 #endif /* G_THREAD_USE_PID_SURROGATE */
 
   thread->retval = thread->thread.func (thread->thread.data);
@@ -697,7 +699,7 @@ g_thread_set_priority (GThread* thread,
 
 #ifdef G_THREAD_USE_PID_SURROGATE
   if (g_thread_use_default_impl)
-    SET_PRIO (real->pid, priority);
+    SET_PRIO (real->tid, priority);
   else
 #endif /* G_THREAD_USE_PID_SURROGATE */
     G_THREAD_CF (thread_set_priority, (void)0, 
@@ -726,7 +728,7 @@ g_thread_self (void)
        G_THREAD_UF (thread_self, (&thread->system_thread));
 
 #ifdef G_THREAD_USE_PID_SURROGATE
-      thread->pid = getpid ();
+      thread->tid = gettid ();
 #endif /* G_THREAD_USE_PID_SURROGATE */
       
       g_private_set (g_thread_specific_private, thread);