mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-06-10 14:50:08 +02:00
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:
parent
dbbb29f608
commit
76c213543a
@ -1,5 +1,9 @@
|
|||||||
2004-02-26 Sebastian Wilhelmi <seppi@seppi.de>
|
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
|
* glib/gatomic.c, glib/gatomic.h: New files to implement atomic
|
||||||
operations for different platforms. Fixes bug #63621.
|
operations for different platforms. Fixes bug #63621.
|
||||||
|
|
||||||
|
@ -1,5 +1,9 @@
|
|||||||
2004-02-26 Sebastian Wilhelmi <seppi@seppi.de>
|
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
|
* glib/gatomic.c, glib/gatomic.h: New files to implement atomic
|
||||||
operations for different platforms. Fixes bug #63621.
|
operations for different platforms. Fixes bug #63621.
|
||||||
|
|
||||||
|
@ -1,5 +1,9 @@
|
|||||||
2004-02-26 Sebastian Wilhelmi <seppi@seppi.de>
|
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
|
* glib/gatomic.c, glib/gatomic.h: New files to implement atomic
|
||||||
operations for different platforms. Fixes bug #63621.
|
operations for different platforms. Fixes bug #63621.
|
||||||
|
|
||||||
|
@ -1,5 +1,9 @@
|
|||||||
2004-02-26 Sebastian Wilhelmi <seppi@seppi.de>
|
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
|
* glib/gatomic.c, glib/gatomic.h: New files to implement atomic
|
||||||
operations for different platforms. Fixes bug #63621.
|
operations for different platforms. Fixes bug #63621.
|
||||||
|
|
||||||
|
@ -1,5 +1,9 @@
|
|||||||
2004-02-26 Sebastian Wilhelmi <seppi@seppi.de>
|
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
|
* glib/gatomic.c, glib/gatomic.h: New files to implement atomic
|
||||||
operations for different platforms. Fixes bug #63621.
|
operations for different platforms. Fixes bug #63621.
|
||||||
|
|
||||||
|
@ -1,5 +1,9 @@
|
|||||||
2004-02-26 Sebastian Wilhelmi <seppi@seppi.de>
|
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
|
* glib/gatomic.c, glib/gatomic.h: New files to implement atomic
|
||||||
operations for different platforms. Fixes bug #63621.
|
operations for different platforms. Fixes bug #63621.
|
||||||
|
|
||||||
|
@ -72,9 +72,6 @@
|
|||||||
/* Source file containing theread implementation */
|
/* Source file containing theread implementation */
|
||||||
#define G_THREAD_SOURCE "gthread-win32.c"
|
#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 */
|
/* A 'va_copy' style function */
|
||||||
#ifndef _MSC_VER
|
#ifndef _MSC_VER
|
||||||
#define G_VA_COPY va_copy
|
#define G_VA_COPY va_copy
|
||||||
|
37
configure.in
37
configure.in
@ -1762,35 +1762,6 @@ int main () {
|
|||||||
AC_DEFINE_UNQUOTED(POSIX_YIELD_FUNC,$posix_yield_func,[The POSIX RT yield function])
|
AC_DEFINE_UNQUOTED(POSIX_YIELD_FUNC,$posix_yield_func,[The POSIX RT yield function])
|
||||||
CPPFLAGS="$glib_save_CPPFLAGS"
|
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
|
elif test x"$have_threads" = xwin32; then
|
||||||
# It's a pointer to a private struct
|
# It's a pointer to a private struct
|
||||||
GLIB_SIZEOF(,struct _GThreadData *, system_thread)
|
GLIB_SIZEOF(,struct _GThreadData *, system_thread)
|
||||||
@ -1864,11 +1835,11 @@ if test $mutex_has_default = yes ; then
|
|||||||
LIBS="$glib_save_LIBS"
|
LIBS="$glib_save_LIBS"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
dnl *****************************
|
dnl ********************************
|
||||||
dnl *** GAtomic tests for gcc ***
|
dnl *** g_atomic_* tests for gcc ***
|
||||||
dnl *****************************
|
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
|
if test x"$GCC" = xyes; then
|
||||||
case $host_cpu in
|
case $host_cpu in
|
||||||
|
@ -1,5 +1,8 @@
|
|||||||
2004-02-26 Sebastian Wilhelmi <seppi@seppi.de>
|
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-overrides.txt, glib/glib-sections.txt,
|
||||||
glib/glib-docs.sgml, glib/tmpl/atomic_operations.sgml: Add docs
|
glib/glib-docs.sgml, glib/tmpl/atomic_operations.sgml: Add docs
|
||||||
for atomic operations.
|
for atomic operations.
|
||||||
|
@ -236,7 +236,7 @@ Specifies the priority of a thread.
|
|||||||
<note>
|
<note>
|
||||||
<para>
|
<para>
|
||||||
It is not guaranteed, that threads with different priorities really
|
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
|
priorities. On other systems (e.g. Solaris) there doesn't seem to be
|
||||||
different scheduling for different priorities. All in all try to avoid
|
different scheduling for different priorities. All in all try to avoid
|
||||||
being dependent on priorities.
|
being dependent on priorities.
|
||||||
@ -320,7 +320,7 @@ error is set, if and only if the function returns %NULL.
|
|||||||
<note>
|
<note>
|
||||||
<para>
|
<para>
|
||||||
It is not guaranteed, that threads with different priorities really
|
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
|
priorities. On other systems (e.g. Solaris) there doesn't seem to be
|
||||||
different scheduling for different priorities. All in all try to avoid
|
different scheduling for different priorities. All in all try to avoid
|
||||||
being dependent on priorities. Use %G_THREAD_PRIORITY_NORMAL here as a
|
being dependent on priorities. Use %G_THREAD_PRIORITY_NORMAL here as a
|
||||||
@ -377,7 +377,7 @@ Changes the priority of @thread to @priority.
|
|||||||
<note>
|
<note>
|
||||||
<para>
|
<para>
|
||||||
It is not guaranteed, that threads with different priorities really
|
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
|
priorities. On other systems (e.g. Solaris) there doesn't seem to be
|
||||||
different scheduling for different priorities. All in all try to avoid
|
different scheduling for different priorities. All in all try to avoid
|
||||||
being dependent on priorities.
|
being dependent on priorities.
|
||||||
@ -1613,8 +1613,6 @@ Any one-time initialization function must have its own unique <structname>GOnce<
|
|||||||
struct.
|
struct.
|
||||||
</para>
|
</para>
|
||||||
|
|
||||||
@status:
|
|
||||||
@retval:
|
|
||||||
@Since: 2.4
|
@Since: 2.4
|
||||||
|
|
||||||
<!-- ##### ENUM GOnceStatus ##### -->
|
<!-- ##### ENUM GOnceStatus ##### -->
|
||||||
|
@ -34,15 +34,6 @@
|
|||||||
|
|
||||||
#include "config.h"
|
#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
|
#ifdef HAVE_UNISTD_H
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#endif
|
#endif
|
||||||
@ -86,24 +77,8 @@ struct _GRealThread
|
|||||||
gpointer private_data;
|
gpointer private_data;
|
||||||
gpointer retval;
|
gpointer retval;
|
||||||
GSystemThread system_thread;
|
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;
|
typedef struct _GStaticPrivateNode GStaticPrivateNode;
|
||||||
struct _GStaticPrivateNode
|
struct _GStaticPrivateNode
|
||||||
{
|
{
|
||||||
@ -179,17 +154,6 @@ g_thread_init_glib (void)
|
|||||||
_g_mem_thread_init ();
|
_g_mem_thread_init ();
|
||||||
_g_messages_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_threads_got_initialized = TRUE;
|
||||||
|
|
||||||
g_thread_specific_private = g_private_new (g_thread_cleanup);
|
g_thread_specific_private = g_private_new (g_thread_cleanup);
|
||||||
@ -583,10 +547,6 @@ g_thread_create_proxy (gpointer data)
|
|||||||
|
|
||||||
g_assert (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 */
|
/* This has to happen before G_LOCK, as that might call g_thread_self */
|
||||||
g_private_set (g_thread_specific_private, data);
|
g_private_set (g_thread_specific_private, data);
|
||||||
|
|
||||||
@ -595,11 +555,6 @@ g_thread_create_proxy (gpointer data)
|
|||||||
G_LOCK (g_thread);
|
G_LOCK (g_thread);
|
||||||
G_UNLOCK (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);
|
thread->retval = thread->thread.func (thread->thread.data);
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -697,13 +652,8 @@ g_thread_set_priority (GThread* thread,
|
|||||||
|
|
||||||
thread->priority = priority;
|
thread->priority = priority;
|
||||||
|
|
||||||
#ifdef G_THREAD_USE_PID_SURROGATE
|
G_THREAD_CF (thread_set_priority, (void)0,
|
||||||
if (g_thread_use_default_impl)
|
(&real->system_thread, priority));
|
||||||
SET_PRIO (real->tid, priority);
|
|
||||||
else
|
|
||||||
#endif /* G_THREAD_USE_PID_SURROGATE */
|
|
||||||
G_THREAD_CF (thread_set_priority, (void)0,
|
|
||||||
(&real->system_thread, priority));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
GThread*
|
GThread*
|
||||||
@ -727,10 +677,6 @@ g_thread_self (void)
|
|||||||
if (g_thread_supported ())
|
if (g_thread_supported ())
|
||||||
G_THREAD_UF (thread_self, (&thread->system_thread));
|
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_private_set (g_thread_specific_private, thread);
|
||||||
|
|
||||||
G_LOCK (g_thread);
|
G_LOCK (g_thread);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user