aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--helpers.c21
1 files changed, 20 insertions, 1 deletions
diff --git a/helpers.c b/helpers.c
index 533769d..104828d 100644
--- a/helpers.c
+++ b/helpers.c
@@ -390,7 +390,23 @@ int setRealtimeScheduling(char *p_name, int prio) {
printf("%s: process name is too long\n", __func__);
return -1;
}
-
+
+#ifdef __APPLE__
+ /* setRealtimeScheduling() requires the function sched_setscheduler() from the
+ * <sched.h> header, which is part of the POSIX Realtime Extension [1]. However
+ * sched_setscheduler() is part of the optional process scheduling features
+ * [1][2], and does not seems to be implemented in macOS 12. Furthermore, the
+ * pidof program is also unavailable in a standard macOS install.
+ *
+ * This functionality could be implemented only for thread using
+ * pthread_attr_setschedparam() and pthread_attr_setschedpolicy(), which are
+ * available in the macOS implementation of POSIX.
+ *
+ * [1]: https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/sched.h.html
+ * [2]: https://unix.org/version2/whatsnew/realtime.html
+ */
+#pragma message ("setRealtimeScheduling() is not implemented (does nothing) in macOS")
+#else
sprintf(shell_cmd, "pidof %s", p_name);
if(exec_shell_command(shell_cmd, str, sizeof(str))) {
printf("%s: Setting realtime scheduling for '%s' failed: '%s'\n", __func__, p_name, str);
@@ -403,5 +419,8 @@ int setRealtimeScheduling(char *p_name, int prio) {
printf("%s: sched_setscheduler failed: %s\n", __func__, strerror(errno));
return -1;
}
+#endif
+
return 0;
}
+