hi all,
so i've tried to make a new scheduling policy for linux. i've
called it SCHED_USERFIFO. the intent is basically to allow a process
ask for x amount of processor time out of every y jiffies. (the user
part is in the hope that the administrator can set rlimits on the
amount of percentage of time requested and allow non-priviledged users
to use this policy without being able to complete hang the box).
it works just like SCHED_FIFO as long as the process doesn't take
more than the amount of time it asked for. if it does try to take
more time, it is allowed to be preempted until the period is over.
i hacked this up quickly, and tested it with the program below. i
was able to get a process in a while (1) loop to take up >99.4% of
processor while still being able to kill it from the console (although
trying to do anything interactive was excruciatingly slow during this
time). when i allowed the process to take up 100% of the period, the
system hung (with respect to other processes) as expected. (tested in
vmware, btw).
this patch is against 2.4.20+lowlatency. it's intended mostly
for people to look at and give feedback. it probably won't work on
systems that use APIC's, it doesn't do any sanity checking, and it
doesn't handle jiffy rollover.
(mostly i'm just sending a mail because i'm pleased with myself
and want to share and get feedback; hopefully this sort of does what i
say it does too).
thanks,
rob
here is the test program, note the two new fields in sched_param:
param.period_reserved
param.period_length
these are specified in system ticks. below i give the program
49 out of every 50 ticks.
------------- testprogram.c ----------------
#include <stdio.h>
#include <sys/types.h>
#include <unistd.h>
//#include <sched.h>
// import these directly
#include <sys/time.h>
#include <sys/poll.h>
#define SCHED_OTHER 0
#define SCHED_FIFO 1
#define SCHED_RR 2
#define SCHED_USERFIFO 3
struct sched_param {
int sched_priority;
/* user fifo stuff */
unsigned long period_length;
unsigned long period_reserved;
};
/* return -1 on failure */
int
set_realtime(void)
{
int r;
struct sched_param param;
pid_t pid;
pid = getpid();
param.sched_priority = 50;
param.period_length = 50;
param.period_reserved = 49;
return sched_setscheduler(pid, SCHED_USERFIFO, ¶m);
}
void
waste_time(void)
{
struct timeval tv, tv_old, tv_tmp, tv_timeout;
struct pollfd ufds;
int res;
int i = 0;
ufds.fd = 2;
ufds.events = POLLPRI;
tv_timeout.tv_sec = 0;
tv_timeout.tv_usec = 600;
i = 0;
while (i<40000000L) {
printf("unf\n");
i++;
}
}
int
main(int argc, char ** argv)
{
int i = 0;
if (set_realtime() < 0) {
fprintf(stderr, "couldn't set scheduler to SCHED_USERFIFO\n");
return -1;
}
waste_time();
return 0;
}
---------------------------------------------
here is the kernel patch.
--- pristine/linux-2.4.20/kernel/sched.c 2003-03-17 23:24:02.000000000 -0500
+++ linux/kernel/sched.c 2003-03-17 22:11:13.000000000 -0500
@@ -188,7 +188,42 @@
* runqueue (taking priorities within processes
* into account).
*/
+
+ if (p->policy == SCHED_USERFIFO) {
+
+ /*
+ * check if we are in the right time period
+ *
+ * XXX if it burns though it's entire period and
+ * into the next ?
+ *
+ */
+ if (jiffies >= p->t_period_end) {
+ /* no, start over from now */
+ p->t_period_start = jiffies;
+ p->t_period_end = p->t_period_length + p->t_period_start;
+ p->t_period_remain = p->t_period_reserved;
+ }
+
+ /*
+ * is there any remaining time ?
+ *
+ */
+
+ if (p->t_period_remain > 0) {
+ weight = 1000 + p->rt_priority;
+ } else {
+ /* redundent, for clarity */
+ weight = -1;
+ }
+ goto out;
+ }
+
+ /* normal RT case */
+
weight = 1000 + p->rt_priority;
+
+
out:
return weight;
}
@@ -939,8 +974,8 @@
else {
retval = -EINVAL;
if (policy != SCHED_FIFO && policy != SCHED_RR &&
- policy != SCHED_OTHER)
- goto out_unlock;
+ policy != SCHED_OTHER && policy != SCHED_USERFIFO)
+ goto out_unlock;
}
/*
@@ -964,6 +999,15 @@
retval = 0;
p->policy = policy;
p->rt_priority = lp.sched_priority;
+
+ if (policy == SCHED_USERFIFO) {
+ /* FIXME: no checks, doesn't handle jiffy rollover */
+ p->t_period_length = lp.period_length;
+ p->t_period_reserved = lp.period_reserved;
+ p->t_period_start = jiffies;
+ p->t_period_end = p->t_period_length + p->t_period_start;
+ p->t_period_remain = p->t_period_reserved;
+ }
current->need_resched = 1;
--- pristine/linux-2.4.20/include/linux/sched.h 2003-03-17 23:24:02.000000000 -0500
+++ linux/include/linux/sched.h 2003-03-17 21:55:04.000000000 -0500
@@ -119,7 +119,7 @@
#define SCHED_OTHER 0
#define SCHED_FIFO 1
#define SCHED_RR 2
-
+#define SCHED_USERFIFO 3
/*
* This is an additional bit set when we want to
* yield the CPU for one re-schedule..
@@ -127,7 +127,10 @@
#define SCHED_YIELD 0x10
struct sched_param {
- int sched_priority;
+ int sched_priority;
+ /* user fifo stuff */
+ unsigned long period_length;
+ unsigned long period_reserved;
};
struct completion;
@@ -419,6 +422,15 @@
/* journalling filesystem info */
void *journal_info;
+
+
+ /* our extra stuff */
+
+ unsigned long t_period_end;
+ unsigned long t_period_start;
+ unsigned long t_period_remain;
+ unsigned long t_period_length;
+ unsigned long t_period_reserved;
};
/*
--- pristine/linux-2.4.20/kernel/timer.c 2002-11-28 18:53:15.000000000 -0500
+++ linux/kernel/timer.c 2003-03-17 22:42:52.000000000 -0500
@@ -610,6 +610,15 @@
p->need_resched = 1;
}
}
+ if (p->policy == SCHED_USERFIFO) {
+
+ if (p->t_period_remain == 0) {
+ p->need_resched = 1;
+ } else {
+ p->t_period_remain--;
+ }
+ }
+
if (p->nice > 0)
kstat.per_cpu_nice[cpu] += user_tick;
else
-------------------- end -------------------------------
----
Robert Melby
Georgia Institute of Technology, Atlanta Georgia, 30332
uucp: ...!{decvax,hplabs,ncar,purdue,rutgers}!gatech!prism!gt4255a
Internet: async(a)cc.gatech.edu
I am pleased to announce Octavian - a realtime software synthesizer for GNU\Linux
operating system.
Octavians's design is like analog modular synthesizers, so it can be used both as
synth and as effect processor. Modular tasks separation allow to extend
possibilities in simple way. Modules can be connected between each other via
channels.
Features:
Audio Input/Output:
- OSS
- JACK
MIDI Input/Output:
- OSS
- ALSA
Plugin's compatability:
- native modules
- LADSPA
This is first pre-beta release. It is a big subject for changes and improvements,
so please send your wishes and bugreports.
Roman
-------------------------------------------
-------- mailto: wormpost(a)mail.ru ---------
-------------------------------------------
Hi.
I released ZynAddSubFX 1.2.0
It is a powerfull software synthesizer for Linux and
Windows, and it is located at
http://zynaddsubfx.sourceforge.net/
News:
1.2.0 - ZynAddSubFX is ported to Windows ;-)
- added internal Virtual Keyboard
- added Configuration window
- added frequency tracking to filter
- improved the OscilGen (harmonic filter, RMS
normalisation, etc..)
- improved the recorder (uses the WAV file
format and it starts only when a key is pressed)
- added filter interpolation if the frequency is
changed very fast (it removes some annoying clicks)
- other improovements, bugfixes, speedups and
cleanups of the code
Paul.
__________________________________________________
Do you Yahoo!?
Yahoo! Platinum - Watch CBS' NCAA March Madness, live on your desktop!
http://platinum.yahoo.com
> I have downloaded the C++ sample code from the echo site. Has anybody
> developed it beyond that point? I will go ahead and set up a web site for
> the management of the development. Are there any suggestions as to the tools
> we will need to collaborate?
Well, base would be CVS and bugzilla. A forum system would be good, as it's
more flexible than a mailing list. phpBB is quite easy to setup, or are you
thinking one of the standard repositories?
I don't have much experience of more advanced tools under Linux; what do you
guys reckon?
It'd be good if we could version control diagrams as well.
My 2 cents ;)
Ranjit.
PyJack 0.1, Initial Release
Download: http://www.a2hd.com/software/
This is a Python module which provides an interface to the Jack Audio
Server. It is possible to access the Jack graph to manipulate port
connections, monitor graph change events, and to perform
soft-realtime audio capture and playback using Numeric Python arrays.
More details, including caveats regarding realtime usage, can be found in
the package documentation.
This software is released under the GPL.
Enjoy,
Andy W. Schmeder
P.S. I will not CC to jackit-devel for future release announcements. This
is only for the initial. Thanks.
--aws
mailto:andy*a2hd,com
http://www.a2hd.com/
>My only interest is in th interface components useful in making a device
>driver.
Sure. I was just curious as to whether there was scope at a later to date to
play with the DSP code.
I've looked at the source again (cheers, David ;) and I can see what David
means, in that for each device (Darla20, Darla24 etc) there is a block of
data defined eg in Darla20DSP.c (in the DSP folder) which is the microcode to
load into the DSP.
So we don't need to mess about with that at this stage, if ever- TBH the hex
doesn't look like code seqs to me (especially the Mia stuff) more like tables
of setup info. Still, as you say, it's irrelevant to what we're doing, which
is to interface that DSP to higher level functions.
Sorry if all this is obvious; hopefully writing up our understanding of what's
going on will help others.
Hello,
Sorry for the OT message but I thought those of you within the UK
might be interested. I am selling lots of Computer Music magazines on
Ebay. I will post to within the UK, and all the auctions start at just
10p (with no reserve), which is pretty good considering each magazine
comes with a CD containing loads of samples and software (and they cost me
5UKP each).
You can see the auctions (with photos and descriptions) at:
http://search.ebay.co.uk/search/search.dll?MfcISAPICommand=GetResult&ebayta…
Thanks for your time.
Cheers,
Bill.
--
Dr. William Bland. Computer Programmer, UK.
www.abstractnonsense.com
It appears to be some kind of latency optimisation for busses, but I can;t
really work out what it does. Theres a whitepaper about it here:
http://www.sis.com/hs_tech/
The claim is that it can reduce system latency by proritising certain
streams. I think. If you could express these priorities to the kernel it
might be of some use.
Anyone know more about it?
- Steve
I found it hilarious that the writer found that Linux is not viable
because none of the *big names* in audio software support it.
Doesn't matter about the companies that actually make the machines
though. Nooooooo sirrreee. It's the software manufacturers who we should
all be sucking up to.
However he is, he is definitely uber cool.
--
Patrick Shirkey - Boost Hardware Ltd.
Http://www.boosthardware.comHttp://www.djcj.org - The Linux Audio Users guide
========================================
Being on stage with the band in front of crowds shouting, "Get off! No!
We want normal music!", I think that was more like acting than anything
I've ever done.
Goldie, 8 Nov, 2002
The Scotsman