Follow Slashdot stories on Twitter

 



Forgot your password?
typodupeerror
×
Programming

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?"
This discussion has been archived. No new comments can be posted.

Ask Slashdot: What's the Most Often-Run Piece of Code -- Ever?

Comments Filter:
  • Re:Bios code? (Score:5, Interesting)

    by Anonymous Coward on Saturday January 18, 2014 @07:05PM (#46001201)

    I would probably have to say whatever is the inner loop on the system idle process in windows.

  • by Anonymous Coward on Saturday January 18, 2014 @07:08PM (#46001231)

    http://en.wikipedia.org/wiki/IEFBR14

    Any time a mainframe does anything with a dataset in a batch job (i.e. allocate, delete, whatever) it runs IEFBR14, a null program, as a target program to satisfy a requirement in how jobs are created.

    This means that banks, retailers, governments, you name it--when they process the back-end records that make modern life functional, IEFBR14 usually gets invoked somewhere.

  • by AuMatar ( 183847 ) on Saturday January 18, 2014 @07:12PM (#46001273)

    for(int i=0; iSOME_LENGTH; i++){
          array[i] = 0;
    }

    Run 100s of times per program, for almost all programs

  • by sk999 ( 846068 ) on Saturday January 18, 2014 @07:14PM (#46001305)

    This gets my vote. Ran it many times myself.

    As an aside, this program, (which did absolutely nothing and, in binary format, was originally only 2 bytes long) had the dubious reputation of being the shortest program with a bug. It failed to clear the register that returned the error code. Oops.

  • by Anonymous Coward on Saturday January 18, 2014 @07:15PM (#46001313)

    The keyboard scan loop in Windows gets my vote.

  • Re:Obligatory (Score:4, Interesting)

    by foobar bazbot ( 3352433 ) on Saturday January 18, 2014 @07:22PM (#46001387)

    I know this is OT, but

    Every Ask Slashdot gets a comment pointing out that it's the dumbest Ask Slashdot ever, I know.

    This time, it's really, really the case.

    True. But more importantly: I never knew /. let us do nested bold levels!

    For anyone too lazy to look at the html source...

    I never knew /. let us do <b>nested <b>bold</b> levels!</b>

  • Re:Bios code? (Score:5, Interesting)

    by Rockoon ( 1252108 ) on Saturday January 18, 2014 @07:54PM (#46001631)
    You are right about the hardware/bios aspect, but arent on the right device.

    (nearly) Every computer has a video device which has a loop running over the frame buffer, outputting pixels to the display output port. Even in the days of regular CGA 320x200 graphics on 60hz monitors that amounted to 3,840,000 iterations per second. We are talking over 3 decades of this going on, on nearly every desktop and laptop computer build during that time (vector displays worked differently) and even in those early days of CGA most of the time those machines were in a text mode with a pixel resolution of 720x240 and still putting out a 60hz of video signal (10,368,000 pixels per second.)

    A single CGA desktop machine in text mode left on since January 1984 would have output 9,816,000,000,000,000 pixels to its display port so far. Thats nearly 10 quadrillion pixels. Even if the average number of running desktop computers over the period were only 1 million (a severe lowball) and used that shitty low resolution at only 60 hz, thats still over a sextillion iterations of that simple pixel outputting loop.

    I would say the average number of running desktops over the period since 1984 is more like 50 million and the average resolution over the period was 1024x768, and the average monitor refresh is 70 hz. My guestimate is about 2.606E+24 iterations of the framebuffer loop, over 2 septillion iterations.
  • Scrypt (Score:3, Interesting)

    by mysidia ( 191772 ) on Saturday January 18, 2014 @07:55PM (#46001643)
    static inline void B(void *blah, uint32_t a)
    {
    uint8_t * z = (uint8_t *)blah;
    z[0] = (a >> 24) & 0xff;
    z[1] = (a >> 16) & 0xff;
    z[2] = (a >> 8) & 0xff;
    z[3] = a & 0xff;

    }
  • Re:For / While in C (Score:2, Interesting)

    by Anonymous Coward on Saturday January 18, 2014 @08:30PM (#46001831)

    I wouldn't trust any C programmer who doesn't have a copy of the standard on his desktop (actual or digital).

    Unlike most standards it's concise and well organized. If you're too lazy to familiarize yourself with it, you're too lazy to write good C code.

  • Re:Solved. Next? (Score:3, Interesting)

    by Anonymous Coward on Saturday January 18, 2014 @11:32PM (#46002729)

    It's not compiled, it's interpreted. If you had a single gigantic mRNA consisting of all your genes, that would be compilation.

    You can think of DNA as source (in an extremely low-level language), mRNA as machine code, and ribosomes as microcontrollers. DNA transcriptase interprets DNA into RNA. In eukaryotes, SNRPs are optimizers (written by a lunatic, but no analogy is perfect) that rearrange the RNA; ribosomes interpret the RNA.
    You've got lots of ribosomes in each cell, so think of each cell as a massively multi-core architecture running a totally asynchronous program.

    So what's the most frequently interpreted gene? Most likely something used by bacteria, since those are the most numerous cells on the planet. Or maybe a routine that's common to all cells. Something that regulates cell division?

    Note that a lot of the stuff that cells do most frequently (say, transport a hydrogen ion across a membrane) does not require DNA synthesis each time. The instructions in DNA are in large part "build a machine out of protein"; there are also a lot of genes involved in *managing* the machine but not much involved in *operating* the machine, if you see what I'm driving at. Obviously, after cell division you need to synthesize more stuff to replace what you've lost (otherwise you'd shrink away to nothing after surprisingly few divisions), but you basically need to sythesize everything; I'm not sure one gene would stand out.

    There are specialized cases where a cell needs to synthesize LOTS of something; salivary glands in insects for example make lots of extra copies of the genes for certain enzymes; some plants do something similar to synthesize various chemicals. But these cases are probably outnumbered by bacteria.

  • Re: For / While in C (Score:3, Interesting)

    by drkim ( 1559875 ) on Saturday January 18, 2014 @11:33PM (#46002731)

    I don't anything about the code that runs in digital watches, but maybe the code that says:

    Is it time to trigger the alarm yet?
    Yes? Trigger the alarm
    No, check the time again.

    I just imagine with the sheer number of watches, cel phones, microwaves, DVRs, etc. out there this would be the most ubiquitous, and constantly running, bit of code.

  • Re: For / While in C (Score:3, Interesting)

    by SydShamino ( 547793 ) on Sunday January 19, 2014 @12:28AM (#46002983)

    Lines of code I've written in HDL execute in hardware once every clock cycle, at, say 100 MHz on maybe 50,000 devices for at least a few years of active use each. That's like 3x10^20 executions alone, and I work for a specialty hardware company which has only sold ~50,000 devices I've designed over the past 13+ years. I'm quite certain other hardware developers have far, far more, and the original question doesn't necessarily seem to require code that executes in a processor versus inferring hardware.

    (And yes, there's one file that I've conveyed from project to project for everything I've designed. It generates a 100 ns time base - a one-clock-cycle-wide pulse every 100 ns - regardless of the clock frequency. It adds a little jitter to synchronize to the time base but makes it easier to change the clock frequency without breaking other real-time dependent timers.)

  • Re: For / While in C (Score:5, Interesting)

    by Zmobie ( 2478450 ) on Sunday January 19, 2014 @01:12AM (#46003223)

    I work with a ton of electrical/controls engineers. Yes it is still probably true, mostly because it is still even cheaper/easier to do this through ladder logic. I forget the context of what we were talking about one day, but one day while talking to one of our SENIOR (30+ years) controls engineers I was explaining some logic that if we had to implement it in C# would take probably 300 lines of code. His reply was simply, psh, I could do that in 3 rungs, don't bother.

THEGODDESSOFTHENETHASTWISTINGFINGERSANDHERVOICEISLIKEAJAVELININTHENIGHTDUDE

Working...