[glib: 1/2] GThread - Check if sched_setattr is allowed by the system policies before depending on it
- From: Philip Withnall <pwithnall src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib: 1/2] GThread - Check if sched_setattr is allowed by the system policies before depending on it
- Date: Wed, 12 Feb 2020 17:05:41 +0000 (UTC)
commit 9308ef9a4b82372c5c94e736a2ec68581309a1e3
Author: Sebastian Dröge <sebastian centricular com>
Date: Mon Feb 10 14:24:48 2020 +0200
GThread - Check if sched_setattr is allowed by the system policies before depending on it
On Fedora it's apparently not allowed so we'll have to fall back to the
thread-spawner thread in GThreadPool instead.
glib/gthread-posix.c | 13 +++++++++++++
1 file changed, 13 insertions(+)
---
diff --git a/glib/gthread-posix.c b/glib/gthread-posix.c
index 9df6d7994..271bb5dbc 100644
--- a/glib/gthread-posix.c
+++ b/glib/gthread-posix.c
@@ -1211,6 +1211,19 @@ g_system_thread_get_scheduler_settings (GThreadSchedulerSettings *scheduler_sett
}
while (res == -1);
+ /* Try setting them on the current thread to see if any system policies are
+ * in place that would disallow doing so */
+ res = syscall (SYS_sched_setattr, tid, scheduler_settings->attr, flags);
+ if (res == -1)
+ {
+ int errsv = errno;
+
+ g_debug ("Failed to set thread scheduler attributes: %s", g_strerror (errsv));
+ g_free (scheduler_settings->attr);
+
+ return FALSE;
+ }
+
return TRUE;
#else
return FALSE;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]