Posted: Wed Apr 23, 2003 7:58 pm Post subject: [Asterisk-Dev] setpriority on non-Linux system
This patch makes Asterisk call setpriority on non-Linux systems
where sched_setscheduler() is not likely to exist
Index: asterisk.c
===================================================================
RCS file: /usr/cvsroot/asterisk/asterisk.c,v
retrieving revision 1.4
diff -u -r1.4 asterisk.c
--- asterisk.c 23 Apr 2003 16:24:09 -0000 1.4
+++ asterisk.c 23 Apr 2003 19:54:47 -0000
@@ -313,6 +313,7 @@
memset(&sched, 0, sizeof(sched));
/* We set ourselves to a high priority, that we might pre-empt everything
else. If your PBX has heavy activity on it, this is a good thing. */
+#ifdef __linux__
if (pri) {
sched.sched_priority = 10;
if (sched_setscheduler(0, SCHED_RR, &sched)) {
@@ -328,6 +329,21 @@
return -1;
}
}
+#else
+ if (pri) {
+ if (setpriority(PRIO_PROCESS, 0, -10) == -1) {
+ ast_log(LOG_WARNING, "Unable to set high priority\n");
+ return -1;
+ } else
+ if (option_verbose)
+ ast_verbose("Set to high priority\n");
+ } else {
+ if (setpriority(PRIO_PROCESS, 0, 0) == -1) {
+ ast_log(LOG_WARNING, "Unable to set normal priority\n");
+ return -1;
+ }
+ }
+#endif
return 0;
}
Posted: Wed Apr 23, 2003 8:17 pm Post subject: [Asterisk-Dev] setpriority on non-Linux system
Just out of interest what is being done with all these patches ?
If they are of interest do I have to save them and apply myself ?
Are they being archived anywhere ?
Are they being applied to the cvs code ?
At 03:58 PM 4/23/2003 -0400, you wrote:
Quote:
This patch makes Asterisk call setpriority on non-Linux systems
where sched_setscheduler() is not likely to exist
Index: asterisk.c
===================================================================
RCS file: /usr/cvsroot/asterisk/asterisk.c,v
retrieving revision 1.4
diff -u -r1.4 asterisk.c
--- asterisk.c 23 Apr 2003 16:24:09 -0000 1.4
+++ asterisk.c 23 Apr 2003 19:54:47 -0000
@@ -313,6 +313,7 @@
memset(&sched, 0, sizeof(sched));
/* We set ourselves to a high priority, that we might pre-empt
everything
else. If your PBX has heavy activity on it, this is a good
thing. */
+#ifdef __linux__
if (pri) {
sched.sched_priority = 10;
if (sched_setscheduler(0, SCHED_RR, &sched)) {
@@ -328,6 +329,21 @@
return -1;
}
}
+#else
+ if (pri) {
+ if (setpriority(PRIO_PROCESS, 0, -10) == -1) {
+ ast_log(LOG_WARNING, "Unable to set high priority\n");
+ return -1;
+ } else
+ if (option_verbose)
+ ast_verbose("Set to high priority\n");
+ } else {
+ if (setpriority(PRIO_PROCESS, 0, 0) == -1) {
+ ast_log(LOG_WARNING, "Unable to set normal
priority\n");
+ return -1;
+ }
+ }
+#endif
return 0;
}
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum