[PD] Latency in realtime on linux

Frank Barknecht fbar at footils.org
Mon Nov 17 20:24:01 CET 2003


Hallo,
Wade McDaniel hat gesagt: // Wade McDaniel wrote:

> What exactly is realtime mode on linux?

This is a bit complicated to explain, but I'll try my best as far as I
understand it: 

Linux, being a true multitasking/multiuser sytem, has many processes
running concurrently. But there is only a limited amount of ressources
available (one or two or more CPUs, ...) so there must be an instance,
that keeps track of when a processes turn is coming. This instance is
the so called Scheduler in the Linux kernel. Normally this Scheduler
just more or less evenly divides the ressources and processor times
between processes. But it is possible, that a process might require
more or more immediate action. This is quite typical in our audio
world: If you want to record something, you cannot afford a single
lost sample, whereas an email transport doesn't care for several 
seconds more wait.

To get the scheduler to play nicer with (audio) processes these
processes need to be "scheduled higher". For security reasons only the
root user is allowed to do that per default. (There are several other
solutions for this: Capabilities, Linux Security Modules and maybe
more).

So if Pd is run by root or has been setuid root, it tries to convince
the Scheduler, that it is more equal than other processes. If you look
into src/s_inter.c, you will see several things happen that have names
with "sched" like "sched_get_priority_max" in set_priority. This is
the realtime scheduling in Pd on Linux (and maybe OS-X).


> I get better latency numbers without using -rt.
> What does that mean?

It means, something is wrong somewhere... :(

> My sound device is a M-Audio Duo (usb) and it always throws weird
> comments on boot, like its not being loaded properly, but then sound
> emerges eventually, so it cant be that wrong...
> 
> 
> My next machine will have a hammerfall card. A good idea, no?

Good, maybe, but you might get another bunch of problems, if you read
the list archive. But that shouldn't stop you. AFAIK the IEM folks
(especially Winfried) is working hard on the Hammerfall/Pd issues.

ciao
-- 
 Frank Barknecht                               _ ______footils.org__




More information about the Pd-list mailing list