On Wednesday 21 February 2001 17:54, Jeffrey Krasky wrote:
> > Hi,
> this may not have to be a real-time question, but I am hoping someone knows
> the answer. Someone told me that I can modify the file rc.sysinit so that
> I can have control of everything that happens when the machine boots. Here
> is my ideal situation: right after the machine is done booting and mounting
> the file systems, it goes and finds my program and runs it. I would like
> my program to first get the current time down to a microsecnd, then "run
> it's function", then get the time again, and output the total execution
> time down to the nearest microsecond. Then I dont care what happens after
> that. I would like to make sure that nothing else could be running, like a
> daemon or something. Is this the way to go or are there better ideas?
If you let the init scripts run, mounting file systems and everything, you're
already going to have all sorts of stuff fired up...
If you want a totally clean system with *no* other processes, you could just
have the kernel load you program instead of init.
I'm not sure that it's worth the effort, though, as processes hanging around
in the hackground won't even be touched by the kernel until they're marked as
ready to run. You can have *thousands* of sleeping processes without
affecting performance the slightest.
Now, if you want to be *really* sure that no other process wakes up when your
program is executing, make it switch to SCHED_FIFO mode, highest priority.
(You need root privileges for that, but I'm assuming that's not a problem
here.)
Try this:
int set_realtime_priority(int policy)
{
struct sched_param schp;
memset(&schp, 0, sizeof(schp));
schp.sched_priority = sched_get_priority_max(policy);
if (sched_setscheduler(0, policy, &schp) != 0) {
perror("sched_setscheduler");
return -1;
}
return 0;
}
(call like this:)
if(set_realtime_priority(SCHED_FIFO) == -1)
{
fprintf(stderr, "ERROR: Can't get realtime priority;"
"run as root for higher reliability.\n");
ret = 0;
}
...and don't forget to do the below, allocate all RAM you need and "stress"
the stack a little, *before* you take the first timestamp, or you might be
interrupted by some swapping when you malloc() or grab more stack space:
if(mlockall(MCL_CURRENT | MCL_FUTURE))
fprintf(stderr, "WARNING: Couldn't mlockall()!\n");
Also, remember that, after this, if your program refuses to go to sleep or
terminate by itself, your only options are Magic SysRq, or the reset button -
user space will freeze over totally. (That's one good reason why you have to
be root to do this.)
//David
.- M A I A -------------------------------------------------.
| Multimedia Application Integration Architecture |
| A Free/Open Source Plugin API for Professional Multimedia |
`----------------------> http://www.linuxaudiodev.com/maia -'
.- David Olofson -------------------------------------------.
| Audio Hacker - Open Source Advocate - Singer - Songwriter |
`--------------------------------------> [EMAIL PROTECTED] -'
-- [rtl] ---
To unsubscribe:
echo "unsubscribe rtl" | mail [EMAIL PROTECTED] OR
echo "unsubscribe rtl <Your_email>" | mail [EMAIL PROTECTED]
--
For more information on Real-Time Linux see:
http://www.rtlinux.org/rtlinux/