Krista's Coding Corner

26.6.2013

Dangerous variables

When it comes to embedded systems, setting a value may have disasterous consequensies.

Why? Because this variable may be a signal, and if a wrong signal is given in a wrong moment you may have frantic arm robot, bungling person lift apparatus or dam that is bursting out way too much water. (Okay, I'm exagerrating a little but even though your device would be smaller, it doesn't mean it wouldn't cause dangerous situations.)

Processors give real electrical signals, so that they can command other components or even devices. Nothing extraordinary here but the thing is that these signals are given just by writing into right memory address.

Many people think that to do something this ”transformational” as giving an electrical signal, you would need to call a function or do something ”big”. Well, that isn't the case, setting a value is enough. Just consider you having faulty pointers that happen to put stuff into totally wrong places. Accidentally there might be a critical misleading signal going forward. (Memory addresses are normally hidden by your operating system and you don't need to touch them directly but this is not the case with embedded systems.)

PS. Sometimes you may see this problem with electrical devices: when a device goes ballistic and starts to blink its all lights (with no purpose), it is quite likely that a pointer has started pointing into incorrect places...

blog comments powered by Disqus