mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-02-12 05:39:21 +01:00
Set the normal PID surrogate priority according to getpid() to avoid
2002-08-06 Sebastian Wilhelmi <wilhelmi@ira.uka.de> * glib/gthread.c: Set the normal PID surrogate priority according to getpid() to avoid errors for niced processes. (#86116) * gthread/gthread-impl.c, gthread/gthread-posix.c, gthread/gthread-solaris.c: Do the same for the posix/dce implementation. Solaris still needs to set priority of the main thread, because all unbound threads will schedule according to that value and it defaults to 0 (the minimal value).
This commit is contained in:
parent
8dd32f5703
commit
3faf95913d
11
ChangeLog
11
ChangeLog
@ -1,3 +1,14 @@
|
|||||||
|
2002-08-06 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
|
||||||
|
|
||||||
|
* glib/gthread.c: Set the normal PID surrogate priority according
|
||||||
|
to getpid() to avoid errors for niced processes. (#86116)
|
||||||
|
|
||||||
|
* gthread/gthread-impl.c, gthread/gthread-posix.c,
|
||||||
|
gthread/gthread-solaris.c: Do the same for the posix/dce
|
||||||
|
implementation. Solaris still needs to set priority of the main
|
||||||
|
thread, because all unbound threads will schedule according to
|
||||||
|
that value and it defaults to 0 (the minimal value).
|
||||||
|
|
||||||
Thu Jul 25 14:23:15 2002 Owen Taylor <otaylor@redhat.com>
|
Thu Jul 25 14:23:15 2002 Owen Taylor <otaylor@redhat.com>
|
||||||
|
|
||||||
* glib/gfileutils.c: Clarify the behavior of g_build_path()
|
* glib/gfileutils.c: Clarify the behavior of g_build_path()
|
||||||
|
@ -1,3 +1,14 @@
|
|||||||
|
2002-08-06 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
|
||||||
|
|
||||||
|
* glib/gthread.c: Set the normal PID surrogate priority according
|
||||||
|
to getpid() to avoid errors for niced processes. (#86116)
|
||||||
|
|
||||||
|
* gthread/gthread-impl.c, gthread/gthread-posix.c,
|
||||||
|
gthread/gthread-solaris.c: Do the same for the posix/dce
|
||||||
|
implementation. Solaris still needs to set priority of the main
|
||||||
|
thread, because all unbound threads will schedule according to
|
||||||
|
that value and it defaults to 0 (the minimal value).
|
||||||
|
|
||||||
Thu Jul 25 14:23:15 2002 Owen Taylor <otaylor@redhat.com>
|
Thu Jul 25 14:23:15 2002 Owen Taylor <otaylor@redhat.com>
|
||||||
|
|
||||||
* glib/gfileutils.c: Clarify the behavior of g_build_path()
|
* glib/gfileutils.c: Clarify the behavior of g_build_path()
|
||||||
|
@ -1,3 +1,14 @@
|
|||||||
|
2002-08-06 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
|
||||||
|
|
||||||
|
* glib/gthread.c: Set the normal PID surrogate priority according
|
||||||
|
to getpid() to avoid errors for niced processes. (#86116)
|
||||||
|
|
||||||
|
* gthread/gthread-impl.c, gthread/gthread-posix.c,
|
||||||
|
gthread/gthread-solaris.c: Do the same for the posix/dce
|
||||||
|
implementation. Solaris still needs to set priority of the main
|
||||||
|
thread, because all unbound threads will schedule according to
|
||||||
|
that value and it defaults to 0 (the minimal value).
|
||||||
|
|
||||||
Thu Jul 25 14:23:15 2002 Owen Taylor <otaylor@redhat.com>
|
Thu Jul 25 14:23:15 2002 Owen Taylor <otaylor@redhat.com>
|
||||||
|
|
||||||
* glib/gfileutils.c: Clarify the behavior of g_build_path()
|
* glib/gfileutils.c: Clarify the behavior of g_build_path()
|
||||||
|
@ -1,3 +1,14 @@
|
|||||||
|
2002-08-06 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
|
||||||
|
|
||||||
|
* glib/gthread.c: Set the normal PID surrogate priority according
|
||||||
|
to getpid() to avoid errors for niced processes. (#86116)
|
||||||
|
|
||||||
|
* gthread/gthread-impl.c, gthread/gthread-posix.c,
|
||||||
|
gthread/gthread-solaris.c: Do the same for the posix/dce
|
||||||
|
implementation. Solaris still needs to set priority of the main
|
||||||
|
thread, because all unbound threads will schedule according to
|
||||||
|
that value and it defaults to 0 (the minimal value).
|
||||||
|
|
||||||
Thu Jul 25 14:23:15 2002 Owen Taylor <otaylor@redhat.com>
|
Thu Jul 25 14:23:15 2002 Owen Taylor <otaylor@redhat.com>
|
||||||
|
|
||||||
* glib/gfileutils.c: Clarify the behavior of g_build_path()
|
* glib/gfileutils.c: Clarify the behavior of g_build_path()
|
||||||
|
@ -1,3 +1,14 @@
|
|||||||
|
2002-08-06 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
|
||||||
|
|
||||||
|
* glib/gthread.c: Set the normal PID surrogate priority according
|
||||||
|
to getpid() to avoid errors for niced processes. (#86116)
|
||||||
|
|
||||||
|
* gthread/gthread-impl.c, gthread/gthread-posix.c,
|
||||||
|
gthread/gthread-solaris.c: Do the same for the posix/dce
|
||||||
|
implementation. Solaris still needs to set priority of the main
|
||||||
|
thread, because all unbound threads will schedule according to
|
||||||
|
that value and it defaults to 0 (the minimal value).
|
||||||
|
|
||||||
Thu Jul 25 14:23:15 2002 Owen Taylor <otaylor@redhat.com>
|
Thu Jul 25 14:23:15 2002 Owen Taylor <otaylor@redhat.com>
|
||||||
|
|
||||||
* glib/gfileutils.c: Clarify the behavior of g_build_path()
|
* glib/gfileutils.c: Clarify the behavior of g_build_path()
|
||||||
|
@ -1,3 +1,14 @@
|
|||||||
|
2002-08-06 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
|
||||||
|
|
||||||
|
* glib/gthread.c: Set the normal PID surrogate priority according
|
||||||
|
to getpid() to avoid errors for niced processes. (#86116)
|
||||||
|
|
||||||
|
* gthread/gthread-impl.c, gthread/gthread-posix.c,
|
||||||
|
gthread/gthread-solaris.c: Do the same for the posix/dce
|
||||||
|
implementation. Solaris still needs to set priority of the main
|
||||||
|
thread, because all unbound threads will schedule according to
|
||||||
|
that value and it defaults to 0 (the minimal value).
|
||||||
|
|
||||||
Thu Jul 25 14:23:15 2002 Owen Taylor <otaylor@redhat.com>
|
Thu Jul 25 14:23:15 2002 Owen Taylor <otaylor@redhat.com>
|
||||||
|
|
||||||
* glib/gfileutils.c: Clarify the behavior of g_build_path()
|
* glib/gfileutils.c: Clarify the behavior of g_build_path()
|
||||||
|
@ -1,3 +1,14 @@
|
|||||||
|
2002-08-06 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
|
||||||
|
|
||||||
|
* glib/gthread.c: Set the normal PID surrogate priority according
|
||||||
|
to getpid() to avoid errors for niced processes. (#86116)
|
||||||
|
|
||||||
|
* gthread/gthread-impl.c, gthread/gthread-posix.c,
|
||||||
|
gthread/gthread-solaris.c: Do the same for the posix/dce
|
||||||
|
implementation. Solaris still needs to set priority of the main
|
||||||
|
thread, because all unbound threads will schedule according to
|
||||||
|
that value and it defaults to 0 (the minimal value).
|
||||||
|
|
||||||
Thu Jul 25 14:23:15 2002 Owen Taylor <otaylor@redhat.com>
|
Thu Jul 25 14:23:15 2002 Owen Taylor <otaylor@redhat.com>
|
||||||
|
|
||||||
* glib/gfileutils.c: Clarify the behavior of g_build_path()
|
* glib/gfileutils.c: Clarify the behavior of g_build_path()
|
||||||
|
@ -88,7 +88,7 @@ struct _GRealThread
|
|||||||
};
|
};
|
||||||
|
|
||||||
#ifdef G_THREAD_USE_PID_SURROGATE
|
#ifdef G_THREAD_USE_PID_SURROGATE
|
||||||
static gint priority_map[] = { 15, 0, -15, -20 };
|
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(pid, prio) G_STMT_START{ \
|
||||||
gint error = setpriority (PRIO_PROCESS, (pid), priority_map[prio]); \
|
gint error = setpriority (PRIO_PROCESS, (pid), priority_map[prio]); \
|
||||||
@ -171,6 +171,17 @@ g_mutex_init (void)
|
|||||||
G_THREAD_UF (thread_self, (&main_thread->system_thread));
|
G_THREAD_UF (thread_self, (&main_thread->system_thread));
|
||||||
|
|
||||||
g_mutex_protect_static_mutex_allocation = g_mutex_new ();
|
g_mutex_protect_static_mutex_allocation = g_mutex_new ();
|
||||||
|
|
||||||
|
#ifdef G_THREAD_USE_PID_SURROGATE
|
||||||
|
priority_map[G_THREAD_PRIORITY_NORMAL] =
|
||||||
|
getpriority (PRIO_PROCESS, (getpid ()));
|
||||||
|
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 */
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -53,13 +53,13 @@ static gint g_thread_priority_map [G_THREAD_PRIORITY_URGENT + 1];
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef PRIORITY_NORMAL_VALUE
|
#ifndef PRIORITY_NORMAL_VALUE
|
||||||
# define PRIORITY_NORMAL_VALUE \
|
# define PRIORITY_NORMAL_VALUE \
|
||||||
(PRIORITY_LOW_VALUE + (PRIORITY_URGENT_VALUE - PRIORITY_LOW_VALUE) * 4 / 10)
|
((PRIORITY_LOW_VALUE * 6 + PRIORITY_URGENT_VALUE * 4) / 10)
|
||||||
#endif /* PRIORITY_NORMAL_VALUE */
|
#endif /* PRIORITY_NORMAL_VALUE */
|
||||||
|
|
||||||
#ifndef PRIORITY_HIGH_VALUE
|
#ifndef PRIORITY_HIGH_VALUE
|
||||||
# define PRIORITY_HIGH_VALUE \
|
# define PRIORITY_HIGH_VALUE \
|
||||||
(PRIORITY_LOW_VALUE + (PRIORITY_URGENT_VALUE - PRIORITY_LOW_VALUE) * 8 / 10)
|
((PRIORITY_NORMAL_VALUE + PRIORITY_URGENT_VALUE * 2) / 3)
|
||||||
#endif /* PRIORITY_HIGH_VALUE */
|
#endif /* PRIORITY_HIGH_VALUE */
|
||||||
|
|
||||||
void g_mutex_init (void);
|
void g_mutex_init (void);
|
||||||
@ -386,9 +386,6 @@ g_thread_init (GThreadFunctions* init)
|
|||||||
* all the thread functions
|
* all the thread functions
|
||||||
*/
|
*/
|
||||||
g_threads_got_initialized = TRUE;
|
g_threads_got_initialized = TRUE;
|
||||||
|
|
||||||
/* we want the main thread to run with normal priority */
|
|
||||||
g_thread_set_priority (g_thread_self(), G_THREAD_PRIORITY_NORMAL);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#else /* !G_THREADS_ENABLED */
|
#else /* !G_THREADS_ENABLED */
|
||||||
|
@ -97,6 +97,7 @@ static gboolean posix_check_cmd_prio_warned = FALSE;
|
|||||||
|
|
||||||
#if defined (POSIX_MIN_PRIORITY) && defined (POSIX_MAX_PRIORITY)
|
#if defined (POSIX_MIN_PRIORITY) && defined (POSIX_MAX_PRIORITY)
|
||||||
# define HAVE_PRIORITIES 1
|
# define HAVE_PRIORITIES 1
|
||||||
|
static gint priority_normal_value;
|
||||||
# ifdef __FreeBSD__
|
# ifdef __FreeBSD__
|
||||||
/* FreeBSD threads use different priority values from the POSIX_
|
/* FreeBSD threads use different priority values from the POSIX_
|
||||||
* defines so we just set them here. The corresponding macros
|
* defines so we just set them here. The corresponding macros
|
||||||
@ -106,23 +107,41 @@ static gboolean posix_check_cmd_prio_warned = FALSE;
|
|||||||
# define PRIORITY_LOW_VALUE 0
|
# define PRIORITY_LOW_VALUE 0
|
||||||
# define PRIORITY_URGENT_VALUE 31
|
# define PRIORITY_URGENT_VALUE 31
|
||||||
# else /* !__FreeBSD__ */
|
# else /* !__FreeBSD__ */
|
||||||
# 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
|
||||||
# endif /* !__FreeBSD__ */
|
# endif /* !__FreeBSD__ */
|
||||||
|
# define PRIORITY_NORMAL_VALUE priority_normal_value
|
||||||
#endif /* POSIX_MIN_PRIORITY && POSIX_MAX_PRIORITY */
|
#endif /* POSIX_MIN_PRIORITY && POSIX_MAX_PRIORITY */
|
||||||
|
|
||||||
static gulong g_thread_min_stack_size = 0;
|
static gulong g_thread_min_stack_size = 0;
|
||||||
|
|
||||||
#define G_MUTEX_SIZE (sizeof (pthread_mutex_t))
|
#define G_MUTEX_SIZE (sizeof (pthread_mutex_t))
|
||||||
|
|
||||||
#ifdef _SC_THREAD_STACK_MIN
|
#if defined(_SC_THREAD_STACK_MIN) || defined (HAVE_PRIORITIES)
|
||||||
#define HAVE_G_THREAD_IMPL_INIT
|
#define HAVE_G_THREAD_IMPL_INIT
|
||||||
static void
|
static void
|
||||||
g_thread_impl_init()
|
g_thread_impl_init()
|
||||||
{
|
{
|
||||||
|
#ifdef _SC_THREAD_STACK_MIN
|
||||||
g_thread_min_stack_size = MAX (sysconf (_SC_THREAD_STACK_MIN), 0);
|
g_thread_min_stack_size = MAX (sysconf (_SC_THREAD_STACK_MIN), 0);
|
||||||
}
|
|
||||||
#endif /* _SC_THREAD_STACK_MIN */
|
#endif /* _SC_THREAD_STACK_MIN */
|
||||||
|
#ifdef HAVE_PRIORITIES
|
||||||
|
# ifdef G_THREADS_IMPL_POSIX
|
||||||
|
{
|
||||||
|
struct sched_param sched;
|
||||||
|
int policy;
|
||||||
|
posix_check_cmd (pthread_getschedparam (pthread_self(), &policy, &sched));
|
||||||
|
priority_normal_value = sched.sched_priority;
|
||||||
|
}
|
||||||
|
# else /* G_THREADS_IMPL_DCE */
|
||||||
|
posix_check_cmd (priority_normal_value =
|
||||||
|
pthread_getprio (*(pthread_t*)thread,
|
||||||
|
g_thread_priority_map [priority]));
|
||||||
|
# endif
|
||||||
|
#endif /* HAVE_PRIORITIES */
|
||||||
|
|
||||||
|
}
|
||||||
|
#endif /* _SC_THREAD_STACK_MIN || HAVE_PRIORITIES */
|
||||||
|
|
||||||
static GMutex *
|
static GMutex *
|
||||||
g_mutex_new_posix_impl (void)
|
g_mutex_new_posix_impl (void)
|
||||||
|
@ -54,6 +54,7 @@ static gulong g_thread_min_stack_size = 0;
|
|||||||
#define G_MUTEX_SIZE (sizeof (mutex_t))
|
#define G_MUTEX_SIZE (sizeof (mutex_t))
|
||||||
|
|
||||||
#define PRIORITY_LOW_VALUE 0
|
#define PRIORITY_LOW_VALUE 0
|
||||||
|
#define PRIORITY_NORMAL_VALUE 50
|
||||||
#define PRIORITY_URGENT_VALUE 127
|
#define PRIORITY_URGENT_VALUE 127
|
||||||
|
|
||||||
#define HAVE_G_THREAD_IMPL_INIT
|
#define HAVE_G_THREAD_IMPL_INIT
|
||||||
@ -61,6 +62,8 @@ static void
|
|||||||
g_thread_impl_init()
|
g_thread_impl_init()
|
||||||
{
|
{
|
||||||
g_thread_min_stack_size = thr_min_stack();
|
g_thread_min_stack_size = thr_min_stack();
|
||||||
|
/* The default priority on Solaris is 0. Set it to something sane */
|
||||||
|
solaris_check_for_error (thr_setprio (thr_self (), PRIORITY_NORMAL_VALUE));
|
||||||
}
|
}
|
||||||
|
|
||||||
static GMutex *
|
static GMutex *
|
||||||
|
Loading…
x
Reference in New Issue
Block a user