diff options
author | Nao Pross <np@0hm.ch> | 2022-03-24 13:22:51 +0100 |
---|---|---|
committer | Nao Pross <np@0hm.ch> | 2022-03-24 13:22:51 +0100 |
commit | 6baa6841e670767d8a8d3c920ae2ce63aedb74ce (patch) | |
tree | a42ac3144bee35d8b9216bb40c2962e70fc69fcb /helpers.c | |
parent | Add Python error handling to video_images_get (diff) | |
download | o3000-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 'helpers.c')
-rw-r--r-- | helpers.c | 21 |
1 files changed, 20 insertions, 1 deletions
@@ -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; } + |