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.
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.
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.
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.
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.
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.
/* 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
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
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
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.
<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.
<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
<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.
struct.
</para>
-@status:
-@retval:
@Since: 2.4
<!-- ##### ENUM GOnceStatus ##### -->
#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
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
{
_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);
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);
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;
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*
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);