[H-GEN] kernel info
Anthony Towns
aj at humbug.org.au
Sun Sep 7 03:37:58 EDT 1997
-----BEGIN PGP SIGNED MESSAGE-----
On Sun, 7 Sep 1997, In memory of Mighty wrote:
> > I have a curious yet unresistable urge to modify my kernel.. more.. to do
> > my current idea, I need to be able to delay for x ms in a kernel c source
> > file.
> > I want to make the kernel beep every second or so for a brief moment after
> > it has been shut down, so I know when to turn the box off when it is
> > headless.
> You could set a flag when it reaches "System Halted" (or whatever,
> my box hasn't stopped running for 41 days now <grin>). Then just add an
> if for that flag in the idle loop, which sets a variable to a large
> negative value, incrementing whenever the idle loop passes, and beeping
> when it gets back to 0....
It might be a nicer move to swap the standard idle task with a beeping
idle task (hmmm, or just have a beeping idle task as standard -- you
know your processor is too fast when it beeps often enough to be
annoying).
Anyway, the applicable bit of sys_reboot() is:
printk( KERN_EMERG, "System halted\n");
(print your average halted message)
syskill(-1,SIGKILL);
(syskill(-x,SIGKILL) seems to be the Evil Overlord's
call -- it ties up process x, makes it watch while
everything else is killed, and then, despite any pleas for
mercy, goes ahead and kills x anyway. And we thought
Linux stood for freedom and justice. BSD forever? It
doesn't kill the current process either, actually)
#if defined(CONFIG_APM) && defined(CONFIG_APM_POWER_OFF)
apm_set_power_state(APM_STATE_OFF);
(turn the power off. This would solve all your
problems, Byron :)
#endif
do_exit(0);
(kill the current process, presumably reboot(1))
My guess is that inserting something akin to the following before the
do_exit(0) (do_exit() doesn't return) might do some good:
{
extern struct task_struct my_beeping_function;
/* fill in the fields "appropriately" in a different
* file, along with the actually beeping function
*/
add_to_runqueue( &my_beeping_function );
}
If you replaced add_to_runqueue() with
task[0] = &my_beeping_function
you could replace the idle task instead of just adding a task, but I'm
not sure that that would be overly pleasant. Strange things might
happen on SMP machines too (not that they don't already).
Filling out the task_struct (<linux/sched.h>) is probably easier said
than done, too.
You _might_ be able to just replace do_exit(0) with your busy loop,
but that might equally well do something nasty.
I believe the beeping_function can then be something along the lines
of
void beeping_function() {
time_t t;
for(;;) {
t = time(); /* or the appropriate low level equiv */
beep_on(); /* or the appr... */
while( time() - t < 30 ) ;
beep_off();
while( time() - t < 1000 ) ;
}
}
If you don't try replacing the idle process you can _probably_ call
sleep( 1 );
to wait for a second, and, I suppose sys_nanosleep() for shorter sleep
periods. Otherwise, you'll have to use a proper busy wait, either with
jiffies (kernel/sched.c), which should continue being updated okay as
far as I can tell, or else the sys_time() call in kernel/time.c.
Hmmm... I reckon replacing do_exit(0) with a busy loop, and counting
jiffies (using jiffiestotimespec() and kernel/sched.c's "jiffies"
variable) would be easiest.
Make up a patch when you get it working, Byron. :)
Cheers,
aj
- --
Anthony Towns <aj at humbug.org.au> <http://student.uq.edu.au/~s343676/>
I don't speak for anyone save myself. PGP encrypted mail preferred.
``Like the ski resort of girls looking for husbands and husbands looking
for girls, the situation is not as symmetrical as it might seem.''
-----BEGIN PGP SIGNATURE-----
Version: 2.6.3ia
Charset: ascii
Comment: Key available at http://student.uq.edu.au/~s343676/aj_key.asc
iQCVAwUBNBJZ3ORRvX9xctrtAQHbUAP/WzWB28GmdOevwYPxF6KYQkdl6VbULfmX
oa/luuMDbxpbAWu+TUJqBcaZeVw3K+PpLeo37RCHMalZVZVytNnbNsLPhtR26nug
XJHmx/J5F3/ml8M/ADsw/CV8yh3vtHFaB2zje2Ba5U2c0pQ2fKWmhikCmP4wxAuC
yTDF3Uloj0I=
=lPi3
-----END PGP SIGNATURE-----
----------------------- HUMBUG General List --------------------------------
echo "unsubscribe general" | mail majordomo at humbug.org.au # To Unsubscribe
More information about the General
mailing list