Remix.run Logo
▲ teddyh a day ago

When Digital Equipment Corporation (DEC) first created the PDP-11, it didn’t realize the mainframe was capable of things DEC hadn’t foreseen. The creators made it with a function that is very fast and has certain interrupt levels, so the function runs around saying, “Oh, I’m running, I’m running a Level 5 job and here comes a Level 7 interrupt. That’s okay, I’m more important. I’ll keep on working here. Oh my God! A Level 2 interrupt. This guy must really want me.” And runs up there.

“What do you want?” he asks.

And the program says, “Oh, ah, am I finished yet?”

“No!” he yells, then runs back down to Level 5 and says to himself, “Okay, fine. I can start again right down here. Oh, I’m finished. Oh! I have this little Level 7 interrupt that I guess I should look at. Oh oh! It says my terminal is free so I can print things on it. Okay, I’ll print such and such.”

There are certain higher levels of interrupt. If one interrupt hits the function as it’s running along, it says, “Oh my God! The line current has dropped to 109 volts! I bet somebody has just flicked the switch, and I’ve only got 329 nanoseconds before the whole system goes down. That’s okay. That gives me more than enough time to save all the registers, load them in the locations they should be in, this, that, and the other thing.”

So the function scurries around, does all this, says, “Ah! Whew, I’ve got a couple of nanoseconds, I guess I’ll wait here until, you know, I go to sleep.” So you flip off the switch and the thing is dead

When you flip the switch on the function jumps up and exclaims, “Oh my God! I’m over 109 volts. I must be on. Well, quick, load everything back up in the accumulators and start running again right where I was.”

— Karla Jennings, The Devouring Fungus: Tales of the Computer Age (1990), chapter 3, The Hacker’s Universe

▲xenadu02 an hour ago | parent | next [-]

This is more or less how modern NVMe/SSD drives with power-safe save work. If they use any DRAM cache they flush that - usually to a reserved SLC cache area with pages already cleaned so the write is fast. They also sync their catalog info to the same area. The on-board capacitors are designed to be sufficient power to allow that to happen reliably. They detect the power drop and kickoff the emergency save process before the capacitors are too discharged to support continued operation.

Somewhat related: my lathe has a DC brushless motor driver board. Its "on-off" is entirely driven by enabling or cutting power. The board senses the disruption of incoming power and starts its shutdown procedure. It then begins driving the motor as a generator, using the power produced to power itself. If it has a braking resistor it also dumps the excess power to that resistor to help the spindle stop faster. If not then the draw of powering itself acts as a load to drag the "generator" down. The result being it doesn't rely on mechanical friction to spin down but stops much faster even though mains voltage was cut off long ago.

▲antonvs 21 hours ago | parent | prev [-]

Many PDP-11 models had magnetic core memory which didn't lose state on a power cycle, which is what allowed this to work. All that needed to be saved on shutdown was the quite small CPU state. Once machines switched to volatile memory, this was no longer possible.

▲cowlevel 4 hours ago | parent [-]

There is actually such a thing as a battrty-backed DIMM, but I believe it requires a special motherboard and is mostly used as an even faster SSD, not regular memory. Linux has APIs for so-called "persistent memory" so you can use it directly and not as a fake SSD, but it's still not regular memory.