[PATCH 5/5] osx: add routines for real-time thread scheduling

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sun, 2011-03-20 at 18:39 +0100, Daniel Mack wrote:
> Code sniplets are based on examples provided by Apple. See
> http://developer.apple.com/library/mac/#documentation/Darwin/Conceptual/KernelProgramming/scheduler/scheduler.html
> ---
>  src/pulsecore/core-util.c |   37 ++++++++++++++++++++++++++++++++++++-
>  1 files changed, 36 insertions(+), 1 deletions(-)
> 
> diff --git a/src/pulsecore/core-util.c b/src/pulsecore/core-util.c
> index a713cae..5747f6e 100644
> --- a/src/pulsecore/core-util.c
> +++ b/src/pulsecore/core-util.c
> @@ -107,6 +107,10 @@
>  
>  #ifdef __APPLE__
>  #include <xlocale.h>
> +#include <mach/mach_init.h>
> +#include <mach/thread_act.h>
> +#include <mach/thread_policy.h>
> +#include <sys/sysctl.h>
>  #endif
>  
>  #ifdef HAVE_DBUS
> @@ -685,7 +689,38 @@ static int set_scheduler(int rtprio) {
>   * the thread is already realtime, don't do anything. */
>  int pa_make_realtime(int rtprio) {
>  
> -#ifdef _POSIX_PRIORITY_SCHEDULING
> +#if defined(OS_IS_DARWIN)
> +    struct thread_time_constraint_policy ttcpolicy;
> +    uint64_t freq = 0;
> +    size_t size = sizeof(freq);
> +    int ret;
> +
> +    ret = sysctlbyname("hw.cpufrequency", &freq, &size, NULL, 0);
> +    if (ret < 0) {
> +        pa_log_info("Unable to read CPU frequency using sysctlbyname()");
> +        return 0;

Shouldn't the return value be negative here? The log message could also
mention that as a consequence of this failure acquiring real-time
scheduling failed too.

-- 
Tanu




[Index of Archives]     [Linux Audio Users]     [AMD Graphics]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux