aboutsummaryrefslogtreecommitdiffstats
path: root/helpers.c
diff options
context:
space:
mode:
authorNao Pross <np@0hm.ch>2022-03-24 13:22:51 +0100
committerNao Pross <np@0hm.ch>2022-03-24 13:22:51 +0100
commit6baa6841e670767d8a8d3c920ae2ce63aedb74ce (patch)
treea42ac3144bee35d8b9216bb40c2962e70fc69fcb /helpers.c
parentAdd Python error handling to video_images_get (diff)
downloado3000-python-binding-6baa6841e670767d8a8d3c920ae2ce63aedb74ce.tar.gz
o3000-python-binding-6baa6841e670767d8a8d3c920ae2ce63aedb74ce.zip
Add precompiler guards to disable setRealtimeScheduling under macOSmacOS
This function seems to be unused in this repository, and does not compile under macOS because sched_setscheduler() is not present in the macOS implementation of the POSIX standard.
Diffstat (limited to '')
-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;
}
+