Why does turning something off and then on again fix the issue most of the time?

We've all been there, whenever a device suddenly stops working correctly your instinctively inclined to switch it off and then on again and almost every time this seems to fix the issue. But why?

Well there is a fairly simple answer. It's just that most electronic devices no matter how seemingly simple or complex have some type of processor in them which have a small amount of memory and run software just like a regular computer. Sometimes however, the software isn't written 100% efficiently and there is a bug in it.

When a device like this crashes or reaches one of those bugs, it's usually because the software is either reading from the wrong memory location, or processed some data in a miscalculated memory location. This can be triggered by any kind of unplanned event or condition that they didn't account for when writing the device's software. When that device is restarted and powers back up, it clears out the memory and starts the software from the beginning. 

When it comes to the technical side, there is quite a few explanations on how these two types of bugs can happen. The first thing to know is the the software gets executed line by line and it gets stored in memory. So the processor in this device has to keep track of which line of code it's running. Also these devices have other circuits attached to them that provide input to the processor. That input can be a sensor or something like a timer. The problem is the input from those sensors and timers can happen any time and it's hard for the processor to predict when that will happen. When that input does happen, the processor has to momentarily pause at whatever line of code is was running and then deal with the input. This is called an interruptbecause it interrupts the processor.

So the processor takes the memory address of the line of code it was about to execute and stores it in memory then it looks at the kind of input it just got and goes somewhere else in the code memory to find out how to deal with that kind of input. When it's done doing that, it goes back to the line of code it saved and starts working from there as if nothing ever happened.

To make this all work properly, the programmers have to be very careful about how they write the software. This is one of the most common places for mistakes to happen that can cause an electronic device to malfunction and it then needs to be turned off and back on again.

article photo credit: Benny Lin

Be my friend!
Never miss a post!