summaryrefslogtreecommitdiff
path: root/audio/csound/patches/patch-ak
blob: 8ace9e9b535f4f4ee06a1375b0433ad3f9a67073 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
$NetBSD: patch-ak,v 1.2 2001/06/29 18:39:03 wiz Exp $

--- new-src/scheduler.c.orig	Sat Dec 12 12:16:30 1998
+++ new-src/scheduler.c
@@ -3,25 +3,28 @@
  *
- * Written by Fred Floberg <emng@geocities.com>
- *
  */
-#include <sched.h>
+
+#include <sys/time.h>
+#include <sys/resource.h>
 #include <stdio.h>
-#include "cs.h"
+
+#define HIGH_PRIORITY -20
+
 void setscheduler(void)
 {
-        struct sched_param sched_param;
 	extern int scheduler_priority;
 
-	if(!scheduler_priority) return; /* Check commandline option */
-        if (sched_getparam(0, &sched_param)<0) {
-                err_printf("Scheduler getparam failed...\n");
-                return;
-        }
-        sched_param.sched_priority = sched_get_priority_max(SCHED_RR);
-        if (!sched_setscheduler(0, SCHED_RR, &sched_param)) {
-                err_printf("Scheduler set to Round Robin with priority %i...\n", sched_param.sched_priority);
-                fflush(stderr);
-                return;
-        }
-        err_printf("!!!Scheduler set to Round Robin with priority %i FAILED!!!\n", sched_param.sched_priority);
+	if (scheduler_priority == 0)
+		return;
+
+	if (setpriority(PRIO_PROCESS, 0, HIGH_PRIORITY) == 0) {
+		err_printf("Scheduler set to priority %i...\n",
+			HIGH_PRIORITY);
+		fflush(stderr);
+		return;
+	}
+
+	err_printf("Scheduler set to priority %i FAILED!!!\n",
+		HIGH_PRIORITY);
+	fflush(stderr);
+	return;
 }