display | more...

This hack on the Linux kernel will make the power LED on a Sparcstation glow inversely proportional to the CPU load. I don't know if this hack will affect performance negatively, but I find it unlikely as turning on and off the LED only involves poking a byte in memory some hundred times a second.

Applies to Sparcstation Classic, and possibly other Sparcstations, running Linux 2.4.x (2.4.18 tested).

How is it done?

The LEDs intensity is modulated by turning it off before the kernel schedules and on when the scheduler has finished. This has the effect that the LED will be on when the system is idle and the idle task is run and off when an actual process is run. The LED will glow with about half of its pre-hacked intensity at its best - probably since a lot of time is spent in the scheduler even when there's nothing to schedule.

It might seem more logical to have the LED glow when there's activity and go out when the system is idle. You might actually try this by simply switching the two additional lines of code - go ahead, I know you want to. This has the problem, though, that the LED will never go out completely but rather glow with about half of its maximum intensity (there's still a lot of time spent in the scheduler!) making it somewhat hard to see the actual CPU load.

The LED is turned on and off by running the macros TURN_OFF_LED() and TURN_ON_LED(). These are defined in a header file somewhere in the dark reigns of the kernel and will write The Secret Number to The Secret Byte of Memory.

The code, dammit, the code!

Modify linux/arch/sparc/kernel/process.c thusly (adding two simple lines):

 * the idle loop on a Sparc... ;)
int cpu_idle(void)
        int ret = -EPERM;

        if (current->pid != 0)
                goto out;

        /* endless idle loop with no priority at all */
        current->nice = 20;
        current->counter = -100;

        for (;;) {
                if (ARCH_SUN4C_SUN4) {
			... (some stuff here) ...
        ret = 0;
        return ret;

Compile and boot!

Log in or register to write something here or to contact authors.