ports/60233: [patch] cdrtools: priority conflicts with cdda2wav/cdrecord
Hanspeter Roth
hampi at rootshell.be
Sun Dec 14 17:10:21 UTC 2003
>Number: 60233
>Category: ports
>Synopsis: [patch] cdrtools: priority conflicts with cdda2wav/cdrecord
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: freebsd-ports-bugs
>State: open
>Quarter:
>Keywords:
>Date-Required:
>Class: change-request
>Submitter-Id: current-users
>Arrival-Date: Sun Dec 14 09:10:10 PST 2003
>Closed-Date:
>Last-Modified:
>Originator: Hanspeter Roth
>Release: FreeBSD 4.9-RELEASE i386
>Organization:
>Environment:
System: FreeBSD snoopy.here 4.9-RELEASE FreeBSD 4.9-RELEASE #0: Sat Nov 29 20:42:43 CET 2003 hampi at snoopy.here:/usr/src/sys/compile/D2 i386
cdrtools-2.0.3
>Description:
Cdda2wav and cdrecord use the highest realtime priority and thus
may conflict with other realtime processes such as isdnd.
I have a system which occasionally hangs if cdrecord is running
while a PPP over ISDN connection is up.
Cdda2wav may also cause the system to spend the CPU in an excessive
amount of time (>80%) in 'interrupt mode' and thus freezing the
display if cdda2wav is run without appropriate -S and an ATAPI drive
uses UDMA33.
>How-To-Repeat:
>Fix:
Use rtprio and renice after cdda2wav or cdrecord has been launched.
Cdda2wav may be run with speed limitation -S to reduce CPU time
spent in 'interrupt mode'.
The patches allow to make use of environment variables to control
the realtime priority and in case of cdda2wav a preset nice priority
will be honored.
--- cdrecord-2.00.3.diff begins here ---
diff -ru cdrtools-2.00.3.orig/cdrecord/cdrecord.1 cdrtools-2.00.3/cdrecord/cdrecord.1
--- cdrtools-2.00.3.orig/cdrecord/cdrecord.1 Tue Dec 24 16:28:40 2002
+++ cdrtools-2.00.3/cdrecord/cdrecord.1 Fri Dec 12 22:26:42 2003
@@ -1379,6 +1379,15 @@
will allow you to write at the full RAW encoding speed a single CPU supports.
This will create high potential of buffer underruns. Use with care.
.TP
+.B CDR_RTPRIORITY
+If this environment variable is set on a system supporting realtime scheduling,
+.B cdrecord
+will try to set it's realtime priority according to
+.BR CDR_RTPRIORITY .
+If set to -1,
+.B cdrecord
+will run with nice priority only.
+.TP
.B RSH
If the
.B RSH
diff -ru cdrtools-2.00.3.orig/cdrecord/cdrecord.c cdrtools-2.00.3/cdrecord/cdrecord.c
--- cdrtools-2.00.3.orig/cdrecord/cdrecord.c Wed May 28 14:06:37 2003
+++ cdrtools-2.00.3/cdrecord/cdrecord.c Fri Dec 12 21:48:50 2003
@@ -3699,6 +3699,8 @@
int pri;
{
struct sched_param scp;
+ char *envvar;
+ int cdrec_priority;
/*
* Verify that scheduling is available
@@ -3711,6 +3713,13 @@
#endif
fillbytes(&scp, sizeof(scp), '\0');
scp.sched_priority = sched_get_priority_max(SCHED_RR) - pri;
+ if ((envvar = getenv("CDR_RTPRIORITY")) != NULL) {
+ cdrec_priority = atoi(envvar);
+ if (cdrec_priority >= sched_get_priority_min(SCHED_RR))
+ scp.sched_priority = cdrec_priority - pri;
+ else
+ return (-1);
+ }
if (sched_setscheduler(0, SCHED_RR, &scp) < 0) {
errmsg("WARNING: Cannot set RR-scheduler\n");
return (-1);
--- cdrecord-2.00.3.diff ends here ---
--- cdda2wav-2.00.3.diff begins here ---
diff -ru cdrtools-2.00.3.orig/cdda2wav/cdda2wav.1 cdrtools-2.00.3/cdda2wav/cdda2wav.1
--- cdrtools-2.00.3.orig/cdda2wav/cdda2wav.1 Tue Nov 26 22:36:56 2002
+++ cdrtools-2.00.3/cdda2wav/cdda2wav.1 Sat Dec 13 15:23:42 2003
@@ -299,6 +299,11 @@
is used to set the device name. The device naming is compatible with Jörg
Schilling's cdrecord package.
.TP
+.B CDDA_RTPRIORITY
+is used to set an alternate realtime priority. If set to -1
+.B cdda2wav
+runs at nice priority only.
+.TP
.B CDDBP_SERVER
is used for cddbp title lookups when supplied.
.TP
diff -ru cdrtools-2.00.3.orig/cdda2wav/cdda2wav.c cdrtools-2.00.3/cdda2wav/cdda2wav.c
--- cdrtools-2.00.3.orig/cdda2wav/cdda2wav.c Thu Nov 21 17:34:33 2002
+++ cdrtools-2.00.3/cdda2wav/cdda2wav.c Sat Dec 13 15:06:13 2003
@@ -966,6 +966,8 @@
static void
switch_to_realtime_priority()
{
+ char *envvar;
+ int priority;
#ifdef _SC_PRIORITY_SCHEDULING
if (sysconf(_SC_PRIORITY_SCHEDULING) == -1) {
errmsg("WARNING: RR-scheduler not available, disabling.\n");
@@ -978,6 +980,13 @@
sched_fifo_min = sched_get_priority_min(SCHED_FIFO);
sched_fifo_max = sched_get_priority_max(SCHED_FIFO);
sched_parms.sched_priority = sched_fifo_max - 1;
+ if ((envvar = getenv("CDDA_RTPRIORITY")) != NULL) {
+ priority = atoi(envvar);
+ if (priority >= sched_fifo_min)
+ sched_parms.sched_priority = priority;
+ else
+ return;
+ }
needroot(0);
if (-1 == sched_setscheduler(getpid(), SCHED_FIFO, &sched_parms)
&& global.quiet != 1)
@@ -2451,7 +2460,9 @@
/* try to get some extra kicks */
needroot(0);
#if defined HAVE_SETPRIORITY
- setpriority(PRIO_PROCESS, 0, -20);
+ if (getpriority(PRIO_PROCESS, 0) == 0) { /* if not preset */
+ setpriority(PRIO_PROCESS, 0, -20);
+ }
#else
# if defined(HAVE_NICE) && (HAVE_NICE == 1)
nice(-20);
--- cdda2wav-2.00.3.diff ends here ---
>Release-Note:
>Audit-Trail:
>Unformatted:
More information about the freebsd-ports-bugs
mailing list