Ask Slashdot: What's the Most Often-Run Piece of Code -- Ever? 533
Hugo Villeneuve writes "What piece of code, in a non-assembler format, has been run the most often, ever, on this planet? By 'most often,' I mean the highest number of executions, regardless of CPU type. For the code in question, let's set a lower limit of 3 consecutive lines. For example, is it:
- A UNIX kernel context switch?
- A SHA2 algorithm for Bitcoin mining on an ASIC?
- A scientific calculation running on a supercomputer?
- A 'for-loop' inside on an obscure microcontroller that runs on all GE appliance since the '60s?"
Re:Bitcoin (Score:5, Informative)
Re:Bios code? (Score:5, Informative)
I would probably have to say whatever is the inner loop on the system idle process in windows.
Ding, we have a winner. Not supercomputer code. Sure, supercomputers are... super and all, but the biggest one only has around 1 million processing cores. How many windoze machines are out there, idling away?
Re:For / While in C (Score:5, Informative)
That actually breaks the C standard, but I suppose control systems aren't much worried about portability.
The ANSI C standard defines two types of implementations: "hosted" and "freestanding". An embedded system would most likely be considered a freestanding implementation, in which case, the entry point function can be whatever the implementation defines it to be. It might not even be named "main" (but if it is, it could return void if that's what the implementation says). That said, C99 allows main() to return void, even in a hosted implementation: 5.1.2.2.1 [coding-guidelines.com] gives "some other implementation-defined manner." as one of the options for main's definition. It notes in 5.1.2.2.3 [coding-guidelines.com] that "If the return type is not compatible with int, the termination status returned to the host environment is unspecified."
Re: IEFBR14 - Mainframe Null Program (Score:4, Informative)
Error? More like bad coding - it relied on the processor clearing the return/exit status register originally, and once the 'error' was 'corrected' it doubled the size of the program (from one BR14 instruction to a load instruction and then the branch instruction).
That code is now 50 years old.
Re:Bios code? (Score:5, Informative)
That is also wrong.
HALT for the CPU means furtherhin it will do nothing.
Perhaps you ment a different opcode?
Halt means it does nothing... until the next interrupt. Which will happen when there's something useful to do.
Re:Obligatory (Score:2, Informative)
I actually think it's an interesting thought experiment. It immediately forces the reader to think about how pieces of code are used in the real world, both within and beyond their intended application. But it is also likely impossible to settle to anyone's satisfaction.
And since it's impossible to settle, it's a total waste of time to even think about it. I don't know what the most often-run piece of code is. I don't have any idea. And I'm pretty sure nobody else on /. does so what's the point of even reading comments? I wouldn't be here if I wasn't bored out of my mind...
This really is the worst ask /. I've ever seen. I wish they'd asked something interesting, like "what did you have for breakfast?" at least I can answer that with some hope of knowing the answer.
Re:For / While in C (Score:5, Informative)
Since no line "maximum" was defined I have to vote for SVCHOST running Windows update on XP....
Just to be accurate... we are shooting the messenger if we blame the SVCHOST process here. It runs various services. The faulty code was in the Windows Update service (wuauserv).
You can see all the respective services with the command tasklist /svc .