For the PID thread priorities surrogate use gettid instead of getpid. This

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).
This commit is contained in:
Sebastian Wilhelmi 2004-02-25 13:23:14 +00:00 committed by Sebastian Wilhelmi
parent 3a69be2e7f
commit 28a267e306
8 changed files with 52 additions and 11 deletions

View 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> 2004-02-24 Sebastian Wilhelmi <seppi@seppi.de>
* glib/grand.c: Add Since: 2.4, where due * glib/grand.c: Add Since: 2.4, where due

View 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> 2004-02-24 Sebastian Wilhelmi <seppi@seppi.de>
* glib/grand.c: Add Since: 2.4, where due * glib/grand.c: Add Since: 2.4, where due

View 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> 2004-02-24 Sebastian Wilhelmi <seppi@seppi.de>
* glib/grand.c: Add Since: 2.4, where due * glib/grand.c: Add Since: 2.4, where due

View 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> 2004-02-24 Sebastian Wilhelmi <seppi@seppi.de>
* glib/grand.c: Add Since: 2.4, where due * glib/grand.c: Add Since: 2.4, where due

View 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> 2004-02-24 Sebastian Wilhelmi <seppi@seppi.de>
* glib/grand.c: Add Since: 2.4, where due * glib/grand.c: Add Since: 2.4, where due

View 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> 2004-02-24 Sebastian Wilhelmi <seppi@seppi.de>
* glib/grand.c: Add Since: 2.4, where due * glib/grand.c: Add Since: 2.4, where due

View File

@ -1767,16 +1767,19 @@ int main () {
[AC_TRY_RUN([ [AC_TRY_RUN([
#include <pthread.h> #include <pthread.h>
#include <sys/types.h> #include <sys/types.h>
#include <linux/unistd.h>
#include <unistd.h> #include <unistd.h>
_syscall0(pid_t,gettid)
pid_t other_pid = 0; pid_t other_pid = 0;
void* func(void* data) {other_pid = getpid();} void* func(void* data) {other_pid = gettid();}
main() main()
{ pthread_t t; { pthread_t t;
void *ret; void *ret;
pthread_create (&t, 0, func, NULL); pthread_create (&t, 0, func, NULL);
pthread_join (t, &ret); pthread_join (t, &ret);
exit (getpid()==other_pid || exit (gettid()==other_pid ||
$posix_priority_min != $posix_priority_max); $posix_priority_min != $posix_priority_max);
} ], } ],
[glib_cv_use_pid_surrogate=yes], [glib_cv_use_pid_surrogate=yes],

View File

@ -39,6 +39,8 @@
#include <sys/time.h> #include <sys/time.h>
#include <sys/resource.h> #include <sys/resource.h>
#include <errno.h> #include <errno.h>
#include <linux/unistd.h>
_syscall0(pid_t,gettid)
#endif /* G_THREAD_USE_PID_SURROGATE */ #endif /* G_THREAD_USE_PID_SURROGATE */
#ifdef HAVE_UNISTD_H #ifdef HAVE_UNISTD_H
@ -85,15 +87,15 @@ struct _GRealThread
gpointer retval; gpointer retval;
GSystemThread system_thread; GSystemThread system_thread;
#ifdef G_THREAD_USE_PID_SURROGATE #ifdef G_THREAD_USE_PID_SURROGATE
pid_t pid; pid_t tid;
#endif /* G_THREAD_USE_PID_SURROGATE */ #endif /* G_THREAD_USE_PID_SURROGATE */
}; };
#ifdef G_THREAD_USE_PID_SURROGATE #ifdef G_THREAD_USE_PID_SURROGATE
static gint priority_map[4]; static gint priority_map[4];
static gboolean prio_warned = FALSE; static gboolean prio_warned = FALSE;
# define SET_PRIO(pid, prio) G_STMT_START{ \ # define SET_PRIO(tid, prio) G_STMT_START{ \
gint error = setpriority (PRIO_PROCESS, (pid), priority_map[prio]); \ gint error = setpriority (PRIO_PROCESS, (tid), priority_map[prio]); \
if (error == -1 && errno == EACCES && !prio_warned) \ if (error == -1 && errno == EACCES && !prio_warned) \
{ \ { \
prio_warned = TRUE; \ prio_warned = TRUE; \
@ -179,7 +181,7 @@ g_thread_init_glib (void)
#ifdef G_THREAD_USE_PID_SURROGATE #ifdef G_THREAD_USE_PID_SURROGATE
priority_map[G_THREAD_PRIORITY_NORMAL] = priority_map[G_THREAD_PRIORITY_NORMAL] =
getpriority (PRIO_PROCESS, (getpid ())); getpriority (PRIO_PROCESS, (gettid ()));
priority_map[G_THREAD_PRIORITY_LOW] = priority_map[G_THREAD_PRIORITY_LOW] =
MIN (20, priority_map[G_THREAD_PRIORITY_NORMAL] + 10); MIN (20, priority_map[G_THREAD_PRIORITY_NORMAL] + 10);
priority_map[G_THREAD_PRIORITY_HIGH] = priority_map[G_THREAD_PRIORITY_HIGH] =
@ -582,7 +584,7 @@ g_thread_create_proxy (gpointer data)
g_assert (data); g_assert (data);
#ifdef G_THREAD_USE_PID_SURROGATE #ifdef G_THREAD_USE_PID_SURROGATE
thread->pid = getpid (); thread->tid = gettid ();
#endif /* G_THREAD_USE_PID_SURROGATE */ #endif /* G_THREAD_USE_PID_SURROGATE */
/* This has to happen before G_LOCK, as that might call g_thread_self */ /* 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 #ifdef G_THREAD_USE_PID_SURROGATE
if (g_thread_use_default_impl) 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 */ #endif /* G_THREAD_USE_PID_SURROGATE */
thread->retval = thread->thread.func (thread->thread.data); thread->retval = thread->thread.func (thread->thread.data);
@ -697,7 +699,7 @@ g_thread_set_priority (GThread* thread,
#ifdef G_THREAD_USE_PID_SURROGATE #ifdef G_THREAD_USE_PID_SURROGATE
if (g_thread_use_default_impl) if (g_thread_use_default_impl)
SET_PRIO (real->pid, priority); SET_PRIO (real->tid, priority);
else else
#endif /* G_THREAD_USE_PID_SURROGATE */ #endif /* G_THREAD_USE_PID_SURROGATE */
G_THREAD_CF (thread_set_priority, (void)0, G_THREAD_CF (thread_set_priority, (void)0,
@ -726,7 +728,7 @@ g_thread_self (void)
G_THREAD_UF (thread_self, (&thread->system_thread)); G_THREAD_UF (thread_self, (&thread->system_thread));
#ifdef G_THREAD_USE_PID_SURROGATE #ifdef G_THREAD_USE_PID_SURROGATE
thread->pid = getpid (); thread->tid = gettid ();
#endif /* G_THREAD_USE_PID_SURROGATE */ #endif /* G_THREAD_USE_PID_SURROGATE */
g_private_set (g_thread_specific_private, thread); g_private_set (g_thread_specific_private, thread);