Ask Slashdot: What's the Most Often-Run Piece of Code -- Ever?
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?"
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 gives "some other implementation-defined manner." as one of the options for main's definition. It notes in 5.1.2.2.3 that "If the return type is not compatible with int, the termination status returned to the host environment is unspecified."
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 .