Removed the PID niceness surrogate for thread priorities as requested by

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.
This commit is contained in:
Sebastian Wilhelmi 2004-02-26 14:44:42 +00:00 committed by Sebastian Wilhelmi
parent dbbb29f608
commit 76c213543a
11 changed files with 36 additions and 97 deletions

View 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.

View 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.

View 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.

View 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.

View 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.

View 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.

View 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

View 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

View 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.

View 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 ##### -->

View File

@ -34,15 +34,6 @@
#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);