mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-06-04 20:00:07 +02:00
Reverted the changes necessary to enlarge the system thread for
2001-02-15 Sebastian Wilhelmi <wilhelmi@ira.uka.de> * acconfig.h, configure.in: Reverted the changes necessary to enlarge the system thread for G_THREAD_USE_PID_SURROGATE. * gthread.c: Now implement G_THREAD_USE_PID_SURROGATE in gthread.c instead of gthread/gthread-posix.c. While the latter has the advantage, that it is conceptually cleaner, it makes g_thread_self_posix_impl _very_ slow and that hurts GStaticRecMutex and other things. So the new version is less clean, but faster. * gthread-posix.c: Removed the G_THREAD_USE_PID_SURROGATE implementation, which is now in gthread.c.
This commit is contained in:
parent
a8786011f3
commit
efb2e89e07
12
ChangeLog
12
ChangeLog
@ -1,3 +1,15 @@
|
|||||||
|
2001-02-15 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
|
||||||
|
|
||||||
|
* acconfig.h, configure.in: Reverted the changes necessary to
|
||||||
|
enlarge the system thread for G_THREAD_USE_PID_SURROGATE.
|
||||||
|
|
||||||
|
* gthread.c: Now implement G_THREAD_USE_PID_SURROGATE in gthread.c
|
||||||
|
instead of gthread/gthread-posix.c. While the latter has the
|
||||||
|
advantage, that it is conceptually cleaner, it makes
|
||||||
|
g_thread_self_posix_impl _very_ slow and that hurts
|
||||||
|
GStaticRecMutex and other things. So the new version is less
|
||||||
|
clean, but faster.
|
||||||
|
|
||||||
2001-02-09 Havoc Pennington <hp@redhat.com>
|
2001-02-09 Havoc Pennington <hp@redhat.com>
|
||||||
|
|
||||||
* gconvert.c (g_convert): don't overwrite errors
|
* gconvert.c (g_convert): don't overwrite errors
|
||||||
|
@ -1,3 +1,15 @@
|
|||||||
|
2001-02-15 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
|
||||||
|
|
||||||
|
* acconfig.h, configure.in: Reverted the changes necessary to
|
||||||
|
enlarge the system thread for G_THREAD_USE_PID_SURROGATE.
|
||||||
|
|
||||||
|
* gthread.c: Now implement G_THREAD_USE_PID_SURROGATE in gthread.c
|
||||||
|
instead of gthread/gthread-posix.c. While the latter has the
|
||||||
|
advantage, that it is conceptually cleaner, it makes
|
||||||
|
g_thread_self_posix_impl _very_ slow and that hurts
|
||||||
|
GStaticRecMutex and other things. So the new version is less
|
||||||
|
clean, but faster.
|
||||||
|
|
||||||
2001-02-09 Havoc Pennington <hp@redhat.com>
|
2001-02-09 Havoc Pennington <hp@redhat.com>
|
||||||
|
|
||||||
* gconvert.c (g_convert): don't overwrite errors
|
* gconvert.c (g_convert): don't overwrite errors
|
||||||
|
@ -1,3 +1,15 @@
|
|||||||
|
2001-02-15 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
|
||||||
|
|
||||||
|
* acconfig.h, configure.in: Reverted the changes necessary to
|
||||||
|
enlarge the system thread for G_THREAD_USE_PID_SURROGATE.
|
||||||
|
|
||||||
|
* gthread.c: Now implement G_THREAD_USE_PID_SURROGATE in gthread.c
|
||||||
|
instead of gthread/gthread-posix.c. While the latter has the
|
||||||
|
advantage, that it is conceptually cleaner, it makes
|
||||||
|
g_thread_self_posix_impl _very_ slow and that hurts
|
||||||
|
GStaticRecMutex and other things. So the new version is less
|
||||||
|
clean, but faster.
|
||||||
|
|
||||||
2001-02-09 Havoc Pennington <hp@redhat.com>
|
2001-02-09 Havoc Pennington <hp@redhat.com>
|
||||||
|
|
||||||
* gconvert.c (g_convert): don't overwrite errors
|
* gconvert.c (g_convert): don't overwrite errors
|
||||||
|
@ -1,3 +1,15 @@
|
|||||||
|
2001-02-15 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
|
||||||
|
|
||||||
|
* acconfig.h, configure.in: Reverted the changes necessary to
|
||||||
|
enlarge the system thread for G_THREAD_USE_PID_SURROGATE.
|
||||||
|
|
||||||
|
* gthread.c: Now implement G_THREAD_USE_PID_SURROGATE in gthread.c
|
||||||
|
instead of gthread/gthread-posix.c. While the latter has the
|
||||||
|
advantage, that it is conceptually cleaner, it makes
|
||||||
|
g_thread_self_posix_impl _very_ slow and that hurts
|
||||||
|
GStaticRecMutex and other things. So the new version is less
|
||||||
|
clean, but faster.
|
||||||
|
|
||||||
2001-02-09 Havoc Pennington <hp@redhat.com>
|
2001-02-09 Havoc Pennington <hp@redhat.com>
|
||||||
|
|
||||||
* gconvert.c (g_convert): don't overwrite errors
|
* gconvert.c (g_convert): don't overwrite errors
|
||||||
|
@ -1,3 +1,15 @@
|
|||||||
|
2001-02-15 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
|
||||||
|
|
||||||
|
* acconfig.h, configure.in: Reverted the changes necessary to
|
||||||
|
enlarge the system thread for G_THREAD_USE_PID_SURROGATE.
|
||||||
|
|
||||||
|
* gthread.c: Now implement G_THREAD_USE_PID_SURROGATE in gthread.c
|
||||||
|
instead of gthread/gthread-posix.c. While the latter has the
|
||||||
|
advantage, that it is conceptually cleaner, it makes
|
||||||
|
g_thread_self_posix_impl _very_ slow and that hurts
|
||||||
|
GStaticRecMutex and other things. So the new version is less
|
||||||
|
clean, but faster.
|
||||||
|
|
||||||
2001-02-09 Havoc Pennington <hp@redhat.com>
|
2001-02-09 Havoc Pennington <hp@redhat.com>
|
||||||
|
|
||||||
* gconvert.c (g_convert): don't overwrite errors
|
* gconvert.c (g_convert): don't overwrite errors
|
||||||
|
@ -1,3 +1,15 @@
|
|||||||
|
2001-02-15 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
|
||||||
|
|
||||||
|
* acconfig.h, configure.in: Reverted the changes necessary to
|
||||||
|
enlarge the system thread for G_THREAD_USE_PID_SURROGATE.
|
||||||
|
|
||||||
|
* gthread.c: Now implement G_THREAD_USE_PID_SURROGATE in gthread.c
|
||||||
|
instead of gthread/gthread-posix.c. While the latter has the
|
||||||
|
advantage, that it is conceptually cleaner, it makes
|
||||||
|
g_thread_self_posix_impl _very_ slow and that hurts
|
||||||
|
GStaticRecMutex and other things. So the new version is less
|
||||||
|
clean, but faster.
|
||||||
|
|
||||||
2001-02-09 Havoc Pennington <hp@redhat.com>
|
2001-02-09 Havoc Pennington <hp@redhat.com>
|
||||||
|
|
||||||
* gconvert.c (g_convert): don't overwrite errors
|
* gconvert.c (g_convert): don't overwrite errors
|
||||||
|
@ -1,3 +1,15 @@
|
|||||||
|
2001-02-15 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
|
||||||
|
|
||||||
|
* acconfig.h, configure.in: Reverted the changes necessary to
|
||||||
|
enlarge the system thread for G_THREAD_USE_PID_SURROGATE.
|
||||||
|
|
||||||
|
* gthread.c: Now implement G_THREAD_USE_PID_SURROGATE in gthread.c
|
||||||
|
instead of gthread/gthread-posix.c. While the latter has the
|
||||||
|
advantage, that it is conceptually cleaner, it makes
|
||||||
|
g_thread_self_posix_impl _very_ slow and that hurts
|
||||||
|
GStaticRecMutex and other things. So the new version is less
|
||||||
|
clean, but faster.
|
||||||
|
|
||||||
2001-02-09 Havoc Pennington <hp@redhat.com>
|
2001-02-09 Havoc Pennington <hp@redhat.com>
|
||||||
|
|
||||||
* gconvert.c (g_convert): don't overwrite errors
|
* gconvert.c (g_convert): don't overwrite errors
|
||||||
|
@ -1,3 +1,15 @@
|
|||||||
|
2001-02-15 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
|
||||||
|
|
||||||
|
* acconfig.h, configure.in: Reverted the changes necessary to
|
||||||
|
enlarge the system thread for G_THREAD_USE_PID_SURROGATE.
|
||||||
|
|
||||||
|
* gthread.c: Now implement G_THREAD_USE_PID_SURROGATE in gthread.c
|
||||||
|
instead of gthread/gthread-posix.c. While the latter has the
|
||||||
|
advantage, that it is conceptually cleaner, it makes
|
||||||
|
g_thread_self_posix_impl _very_ slow and that hurts
|
||||||
|
GStaticRecMutex and other things. So the new version is less
|
||||||
|
clean, but faster.
|
||||||
|
|
||||||
2001-02-09 Havoc Pennington <hp@redhat.com>
|
2001-02-09 Havoc Pennington <hp@redhat.com>
|
||||||
|
|
||||||
* gconvert.c (g_convert): don't overwrite errors
|
* gconvert.c (g_convert): don't overwrite errors
|
||||||
|
@ -45,7 +45,6 @@
|
|||||||
|
|
||||||
#undef ENABLE_NLS
|
#undef ENABLE_NLS
|
||||||
#undef GETTEXT_PACKAGE
|
#undef GETTEXT_PACKAGE
|
||||||
#undef GLIB_SIZEOF_SYSTEM_THREAD
|
|
||||||
#undef GLIB_LOCALE_DIR
|
#undef GLIB_LOCALE_DIR
|
||||||
#undef HAVE_GETTEXT
|
#undef HAVE_GETTEXT
|
||||||
#undef HAVE_LC_MESSAGES
|
#undef HAVE_LC_MESSAGES
|
||||||
|
@ -1064,7 +1064,7 @@ if test x"$have_threads" != xnone; then
|
|||||||
glib_save_CPPFLAGS="$CPPFLAGS"
|
glib_save_CPPFLAGS="$CPPFLAGS"
|
||||||
CPPFLAGS="$CPPFLAGS $GTHREAD_COMPILE_IMPL_DEFINES"
|
CPPFLAGS="$CPPFLAGS $GTHREAD_COMPILE_IMPL_DEFINES"
|
||||||
dnl we might grow sizeof(pthread_t) later on, so use a dummy name here
|
dnl we might grow sizeof(pthread_t) later on, so use a dummy name here
|
||||||
GLIB_SIZEOF([#include <pthread.h>], pthread_t, core_system_thread)
|
GLIB_SIZEOF([#include <pthread.h>], pthread_t, system_thread)
|
||||||
# This is not AC_CHECK_FUNC to also work with function
|
# This is not AC_CHECK_FUNC to also work with function
|
||||||
# name mangling in header files.
|
# name mangling in header files.
|
||||||
AC_MSG_CHECKING(for pthread_attr_setstacksize)
|
AC_MSG_CHECKING(for pthread_attr_setstacksize)
|
||||||
@ -1118,7 +1118,6 @@ if test x"$have_threads" != xnone; then
|
|||||||
CPPFLAGS="$glib_save_CPPFLAGS"
|
CPPFLAGS="$glib_save_CPPFLAGS"
|
||||||
|
|
||||||
AC_MSG_CHECKING(whether to use the PID niceness surrogate for thread priorities)
|
AC_MSG_CHECKING(whether to use the PID niceness surrogate for thread priorities)
|
||||||
glib_system_thread_size_growth=0
|
|
||||||
AC_TRY_RUN([#include <pthread.h>
|
AC_TRY_RUN([#include <pthread.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
@ -1135,12 +1134,8 @@ if test x"$have_threads" != xnone; then
|
|||||||
}],
|
}],
|
||||||
[AC_MSG_RESULT(yes),
|
[AC_MSG_RESULT(yes),
|
||||||
AC_DEFINE(G_THREAD_USE_PID_SURROGATE, 1, [whether to use the PID niceness surrogate for thread priorities])
|
AC_DEFINE(G_THREAD_USE_PID_SURROGATE, 1, [whether to use the PID niceness surrogate for thread priorities])
|
||||||
glib_system_thread_size_growth=$ac_cv_sizeof_long
|
|
||||||
],
|
],
|
||||||
[AC_MSG_RESULT(no)])
|
[AC_MSG_RESULT(no)])
|
||||||
dnl make sure both glib_cv_sizeof_system_thread and GLIB_SIZEOF_SYSTEM_THREAD are setup
|
|
||||||
glib_cv_sizeof_system_thread=`expr $glib_cv_sizeof_core_system_thread + $glib_system_thread_size_growth`
|
|
||||||
AC_DEFINE_UNQUOTED(GLIB_SIZEOF_SYSTEM_THREAD, $glib_cv_sizeof_system_thread)
|
|
||||||
else # solaris threads
|
else # solaris threads
|
||||||
GLIB_SIZEOF([#include <thread.h>], thread_t, system_thread)
|
GLIB_SIZEOF([#include <thread.h>], thread_t, system_thread)
|
||||||
fi
|
fi
|
||||||
|
@ -35,6 +35,13 @@
|
|||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "glib.h"
|
#include "glib.h"
|
||||||
|
|
||||||
|
#ifdef G_THREAD_USE_PID_SURROGATE
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <sys/time.h>
|
||||||
|
#include <sys/resource.h>
|
||||||
|
#include <errno.h>
|
||||||
|
#endif /* G_THREAD_USE_PID_SURROGATE */
|
||||||
|
|
||||||
#ifdef HAVE_UNISTD_H
|
#ifdef HAVE_UNISTD_H
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#endif
|
#endif
|
||||||
@ -68,8 +75,24 @@ struct _GRealThread
|
|||||||
gpointer arg;
|
gpointer arg;
|
||||||
gpointer private_data;
|
gpointer private_data;
|
||||||
GSystemThread system_thread;
|
GSystemThread system_thread;
|
||||||
|
#ifdef G_THREAD_USE_PID_SURROGATE
|
||||||
|
pid_t pid;
|
||||||
|
#endif /* G_THREAD_USE_PID_SURROGATE */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#ifdef G_THREAD_USE_PID_SURROGATE
|
||||||
|
static gint priority_map[] = { 15, 0, -15, -20 };
|
||||||
|
static gboolean prio_warned = FALSE;
|
||||||
|
# define SET_PRIO(pid, prio) G_STMT_START{ \
|
||||||
|
gint error = setpriority (PRIO_PROCESS, (pid), 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
|
||||||
{
|
{
|
||||||
@ -485,6 +508,10 @@ g_thread_create_proxy (gpointer data)
|
|||||||
|
|
||||||
g_assert (data);
|
g_assert (data);
|
||||||
|
|
||||||
|
#ifdef G_THREAD_USE_PID_SURROGATE
|
||||||
|
thread->pid = getpid ();
|
||||||
|
#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);
|
||||||
|
|
||||||
@ -492,6 +519,9 @@ g_thread_create_proxy (gpointer data)
|
|||||||
before thread->func is called. See g_thread_create. */
|
before thread->func is called. See g_thread_create. */
|
||||||
G_LOCK (g_thread);
|
G_LOCK (g_thread);
|
||||||
G_UNLOCK (g_thread);
|
G_UNLOCK (g_thread);
|
||||||
|
|
||||||
|
if (g_thread_use_default_impl)
|
||||||
|
SET_PRIO (thread->pid, thread->thread.priority);
|
||||||
|
|
||||||
thread->func (thread->arg);
|
thread->func (thread->arg);
|
||||||
}
|
}
|
||||||
@ -573,7 +603,14 @@ g_thread_set_priority (GThread* thread,
|
|||||||
g_return_if_fail (priority <= G_THREAD_PRIORITY_URGENT);
|
g_return_if_fail (priority <= G_THREAD_PRIORITY_URGENT);
|
||||||
|
|
||||||
thread->priority = priority;
|
thread->priority = priority;
|
||||||
G_THREAD_CF (thread_set_priority, (void)0, (&real->system_thread, priority));
|
|
||||||
|
#ifdef G_THREAD_USE_PID_SURROGATE
|
||||||
|
if (g_thread_use_default_impl)
|
||||||
|
SET_PRIO (real->pid, priority);
|
||||||
|
else
|
||||||
|
#endif /* G_THREAD_USE_PID_SURROGATE */
|
||||||
|
G_THREAD_CF (thread_set_priority, (void)0,
|
||||||
|
(&real->system_thread, priority));
|
||||||
}
|
}
|
||||||
|
|
||||||
GThread*
|
GThread*
|
||||||
@ -598,6 +635,10 @@ 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->pid = getpid ();
|
||||||
|
#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);
|
||||||
|
43
gthread.c
43
gthread.c
@ -35,6 +35,13 @@
|
|||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "glib.h"
|
#include "glib.h"
|
||||||
|
|
||||||
|
#ifdef G_THREAD_USE_PID_SURROGATE
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <sys/time.h>
|
||||||
|
#include <sys/resource.h>
|
||||||
|
#include <errno.h>
|
||||||
|
#endif /* G_THREAD_USE_PID_SURROGATE */
|
||||||
|
|
||||||
#ifdef HAVE_UNISTD_H
|
#ifdef HAVE_UNISTD_H
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#endif
|
#endif
|
||||||
@ -68,8 +75,24 @@ struct _GRealThread
|
|||||||
gpointer arg;
|
gpointer arg;
|
||||||
gpointer private_data;
|
gpointer private_data;
|
||||||
GSystemThread system_thread;
|
GSystemThread system_thread;
|
||||||
|
#ifdef G_THREAD_USE_PID_SURROGATE
|
||||||
|
pid_t pid;
|
||||||
|
#endif /* G_THREAD_USE_PID_SURROGATE */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#ifdef G_THREAD_USE_PID_SURROGATE
|
||||||
|
static gint priority_map[] = { 15, 0, -15, -20 };
|
||||||
|
static gboolean prio_warned = FALSE;
|
||||||
|
# define SET_PRIO(pid, prio) G_STMT_START{ \
|
||||||
|
gint error = setpriority (PRIO_PROCESS, (pid), 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
|
||||||
{
|
{
|
||||||
@ -485,6 +508,10 @@ g_thread_create_proxy (gpointer data)
|
|||||||
|
|
||||||
g_assert (data);
|
g_assert (data);
|
||||||
|
|
||||||
|
#ifdef G_THREAD_USE_PID_SURROGATE
|
||||||
|
thread->pid = getpid ();
|
||||||
|
#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);
|
||||||
|
|
||||||
@ -492,6 +519,9 @@ g_thread_create_proxy (gpointer data)
|
|||||||
before thread->func is called. See g_thread_create. */
|
before thread->func is called. See g_thread_create. */
|
||||||
G_LOCK (g_thread);
|
G_LOCK (g_thread);
|
||||||
G_UNLOCK (g_thread);
|
G_UNLOCK (g_thread);
|
||||||
|
|
||||||
|
if (g_thread_use_default_impl)
|
||||||
|
SET_PRIO (thread->pid, thread->thread.priority);
|
||||||
|
|
||||||
thread->func (thread->arg);
|
thread->func (thread->arg);
|
||||||
}
|
}
|
||||||
@ -573,7 +603,14 @@ g_thread_set_priority (GThread* thread,
|
|||||||
g_return_if_fail (priority <= G_THREAD_PRIORITY_URGENT);
|
g_return_if_fail (priority <= G_THREAD_PRIORITY_URGENT);
|
||||||
|
|
||||||
thread->priority = priority;
|
thread->priority = priority;
|
||||||
G_THREAD_CF (thread_set_priority, (void)0, (&real->system_thread, priority));
|
|
||||||
|
#ifdef G_THREAD_USE_PID_SURROGATE
|
||||||
|
if (g_thread_use_default_impl)
|
||||||
|
SET_PRIO (real->pid, priority);
|
||||||
|
else
|
||||||
|
#endif /* G_THREAD_USE_PID_SURROGATE */
|
||||||
|
G_THREAD_CF (thread_set_priority, (void)0,
|
||||||
|
(&real->system_thread, priority));
|
||||||
}
|
}
|
||||||
|
|
||||||
GThread*
|
GThread*
|
||||||
@ -598,6 +635,10 @@ 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->pid = getpid ();
|
||||||
|
#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);
|
||||||
|
@ -1,3 +1,8 @@
|
|||||||
|
2001-02-15 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
|
||||||
|
|
||||||
|
* gthread-posix.c: Removed the G_THREAD_USE_PID_SURROGATE
|
||||||
|
implementation, which is now in gthread.c.
|
||||||
|
|
||||||
2001-01-30 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
|
2001-01-30 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
|
||||||
|
|
||||||
* gthread-impl.c (g_thread_init_with_errorcheck_mutexes): Call
|
* gthread-impl.c (g_thread_init_with_errorcheck_mutexes): Call
|
||||||
|
@ -45,15 +45,6 @@
|
|||||||
#include <sched.h>
|
#include <sched.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef G_THREAD_USE_PID_SURROGATE
|
|
||||||
# include <sys/resource.h>
|
|
||||||
# define PID_IN_THREAD(thread) (*(pid_t*)(((gchar*)thread)+sizeof(pthread_t)))
|
|
||||||
# define SET_PRIO(pid, prio) \
|
|
||||||
posix_check_cmd_prio ((setpriority (PRIO_PROCESS, (pid), \
|
|
||||||
g_thread_priority_map [prio]) == -1) ? \
|
|
||||||
(errno == EACCES ? EPERM : errno ): 0)
|
|
||||||
#endif /* G_THREAD_USE_PID_SURROGATE */
|
|
||||||
|
|
||||||
#define posix_check_err(err, name) G_STMT_START{ \
|
#define posix_check_err(err, name) G_STMT_START{ \
|
||||||
int error = (err); \
|
int error = (err); \
|
||||||
if (error) \
|
if (error) \
|
||||||
@ -104,12 +95,7 @@ static gboolean posix_check_cmd_prio_warned = FALSE;
|
|||||||
# error This should not happen. Contact the GLib team.
|
# error This should not happen. Contact the GLib team.
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef G_THREAD_USE_PID_SURROGATE
|
#if defined (POSIX_MIN_PRIORITY) && defined (POSIX_MAX_PRIORITY)
|
||||||
# define PRIORITY_LOW_VALUE 15
|
|
||||||
# define PRIORITY_NORMAL_VALUE 0
|
|
||||||
# define PRIORITY_HIGH_VALUE -15
|
|
||||||
# define PRIORITY_URGENT_VALUE -20
|
|
||||||
#elif defined (POSIX_MIN_PRIORITY) && defined (POSIX_MAX_PRIORITY)
|
|
||||||
# define HAVE_PRIORITIES 1
|
# define HAVE_PRIORITIES 1
|
||||||
# define PRIORITY_LOW_VALUE POSIX_MIN_PRIORITY
|
# define PRIORITY_LOW_VALUE POSIX_MIN_PRIORITY
|
||||||
# define PRIORITY_URGENT_VALUE POSIX_MAX_PRIORITY
|
# define PRIORITY_URGENT_VALUE POSIX_MAX_PRIORITY
|
||||||
@ -265,27 +251,6 @@ g_private_get_posix_impl (GPrivate * private_key)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef G_THREAD_USE_PID_SURROGATE
|
|
||||||
struct proxy_data
|
|
||||||
{
|
|
||||||
GThreadFunc thread_func;
|
|
||||||
gpointer arg;
|
|
||||||
gpointer thread;
|
|
||||||
GThreadPriority priority;
|
|
||||||
};
|
|
||||||
|
|
||||||
static void
|
|
||||||
g_thread_create_posix_impl_proxy (struct proxy_data *data)
|
|
||||||
{
|
|
||||||
GThreadFunc thread_func = data->thread_func;
|
|
||||||
GThreadFunc arg = data->arg;
|
|
||||||
PID_IN_THREAD (data->thread) = getpid();
|
|
||||||
SET_PRIO (PID_IN_THREAD (data->thread), data->priority);
|
|
||||||
g_free (data);
|
|
||||||
thread_func (arg);
|
|
||||||
}
|
|
||||||
#endif /* G_THREAD_USE_PID_SURROGATE */
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
g_thread_create_posix_impl (GThreadFunc thread_func,
|
g_thread_create_posix_impl (GThreadFunc thread_func,
|
||||||
gpointer arg,
|
gpointer arg,
|
||||||
@ -325,35 +290,21 @@ g_thread_create_posix_impl (GThreadFunc thread_func,
|
|||||||
joinable ? PTHREAD_CREATE_JOINABLE : PTHREAD_CREATE_DETACHED));
|
joinable ? PTHREAD_CREATE_JOINABLE : PTHREAD_CREATE_DETACHED));
|
||||||
#endif /* G_THREADS_IMPL_POSIX */
|
#endif /* G_THREADS_IMPL_POSIX */
|
||||||
|
|
||||||
#ifdef G_THREAD_USE_PID_SURROGATE
|
#ifdef HAVE_PRIORITIES
|
||||||
{
|
# ifdef G_THREADS_IMPL_POSIX
|
||||||
struct proxy_data *data = g_new (struct proxy_data, 1);
|
|
||||||
data->thread_func = thread_func;
|
|
||||||
data->arg = arg;
|
|
||||||
data->thread = thread;
|
|
||||||
data->priority = priority;
|
|
||||||
PID_IN_THREAD (thread) = 0;
|
|
||||||
ret = posix_error (pthread_create (thread, &attr, (void* (*)(void*))
|
|
||||||
g_thread_create_posix_impl_proxy,
|
|
||||||
data));
|
|
||||||
}
|
|
||||||
#else /* G_THREAD_USE_PID_SURROGATE */
|
|
||||||
# ifdef HAVE_PRIORITIES
|
|
||||||
# ifdef G_THREADS_IMPL_POSIX
|
|
||||||
{
|
{
|
||||||
struct sched_param sched;
|
struct sched_param sched;
|
||||||
posix_check_cmd (pthread_attr_getschedparam (&attr, &sched));
|
posix_check_cmd (pthread_attr_getschedparam (&attr, &sched));
|
||||||
sched.sched_priority = g_thread_priority_map [priority];
|
sched.sched_priority = g_thread_priority_map [priority];
|
||||||
posix_check_cmd_prio (pthread_attr_setschedparam (&attr, &sched));
|
posix_check_cmd_prio (pthread_attr_setschedparam (&attr, &sched));
|
||||||
}
|
}
|
||||||
# else /* G_THREADS_IMPL_DCE */
|
# else /* G_THREADS_IMPL_DCE */
|
||||||
posix_check_cmd_prio
|
posix_check_cmd_prio
|
||||||
(pthread_attr_setprio (&attr, g_thread_priority_map [priority]));
|
(pthread_attr_setprio (&attr, g_thread_priority_map [priority]));
|
||||||
# endif /* G_THREADS_IMPL_DCE */
|
# endif /* G_THREADS_IMPL_DCE */
|
||||||
# endif /* HAVE_PRIORITIES */
|
#endif /* HAVE_PRIORITIES */
|
||||||
ret = posix_error (pthread_create (thread, &attr,
|
ret = posix_error (pthread_create (thread, &attr,
|
||||||
(void* (*)(void*))thread_func, arg));
|
(void* (*)(void*))thread_func, arg));
|
||||||
#endif /* !G_THREAD_USE_PID_SURROGATE */
|
|
||||||
|
|
||||||
posix_check_cmd (pthread_attr_destroy (&attr));
|
posix_check_cmd (pthread_attr_destroy (&attr));
|
||||||
|
|
||||||
@ -411,21 +362,13 @@ g_thread_set_priority_posix_impl (gpointer thread, GThreadPriority priority)
|
|||||||
posix_check_cmd_prio (pthread_setprio (*(pthread_t*)thread,
|
posix_check_cmd_prio (pthread_setprio (*(pthread_t*)thread,
|
||||||
g_thread_priority_map [priority]));
|
g_thread_priority_map [priority]));
|
||||||
# endif
|
# endif
|
||||||
#elif defined (G_THREAD_USE_PID_SURROGATE)
|
#endif /* HAVE_PRIORITIES */
|
||||||
/* If the addressed thread hasn't yet been able to provide it's pid,
|
|
||||||
* we ignore the request. Should be more than rare */
|
|
||||||
if (PID_IN_THREAD (thread) != 0)
|
|
||||||
SET_PRIO (PID_IN_THREAD (thread), priority);
|
|
||||||
#endif /* G_THREAD_USE_PID_SURROGATE */
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
g_thread_self_posix_impl (gpointer thread)
|
g_thread_self_posix_impl (gpointer thread)
|
||||||
{
|
{
|
||||||
*(pthread_t*)thread = pthread_self();
|
*(pthread_t*)thread = pthread_self();
|
||||||
#ifdef G_THREAD_USE_PID_SURROGATE
|
|
||||||
PID_IN_THREAD (thread) = getpid();
|
|
||||||
#endif /* G_THREAD_USE_PID_SURROGATE */
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static GThreadFunctions g_thread_functions_for_glib_use_default =
|
static GThreadFunctions g_thread_functions_for_glib_use_default =
|
||||||
|
Loading…
x
Reference in New Issue
Block a user