[From the last episode: We took a quick look at softwareIn this context, "software" refers to functions in an IoT device that are implemented by running instructions through some kind of processor. It's distinct from "hardware," where functions are built into a silicon chip or some other component. and how compilers create machine codeThe lowest-level representation of a computer program. It consists only of 1s and 0s, which a computer (or a machine) understands, but which is VERY hard for humans to understand..]
We’ve seen the big-picture version of what a processorA computer chip that does computing work for a computer. It may do general work (like in your home computer) or it may do specialized work (like some of the processors in your smartphone). does. And we’ve seen software that runs on it. But, depending on the kind of system we’re looking at, it may not be that simple.
Accessing Resources
A computer or IoTThe Internet of Things. A broad term covering many different applications where "things" are interconnected through the internet. device has lots of “resources” on it. With a pure computer, memory is a resource. On an IoT device, memory and sensorsA device that can measure something about its environment. Examples are movement, light, color, moisture, pressure, and many more. are examples of resources. And the software that runs needs to be able to access those resources. For example, the software may need to grab the current reading from a temperature sensor. Or it might need to use some memory for something it’s working on. Does it just go directly to those resources?
The answer is… probably not. (We’ll come back to the rare cases when the answer is, “Yes” further down.) There are lots of reasons why you may not want to work directly with those resources. A couple of examples:
- If you get directly to memory, then you might get to stuff that you shouldn’t mess with. Some computers have more than one job going at a time, and you don’t want the software for one job to mess with the memory for another job.
- Specific resources take a lot of detail to get to. If the software has to do that itself, then you might have to change the software in lots of little ways each time you adapt it to a different system. For instance, if there are multiple versions of some IoT system, you want the software to work easily on all of them with, if possible, no changes.
So what to do?
Operating Systems to the Rescue
This is where the operating system, or OS, comes in. Think of it as a layer of software that works at the low system level. It protects the system and provides “services” to the software above. Rather than the software grabbing memory directly, the software asks the OS for memory. The OS knows which memory is free and which is in use – as well as which memory the software has permission to access – and so the OS figures out what memory to allocate and “gives” it to the software.
The OS also hides the details of a lot of those resources. So, rather than the software having to know exactly how to access a specific sensor (which might be different on a different system), the software asks the OS to get the sensor reading.
The OS adapts to the details of each system. Once that’s done, higher-level software can run on the systemsThis is a very generic term for any collection of components that, all together, can do something. Systems can be built from subsystems. Examples are your cell phone; your computer; the radio in your car; anything that seems like a "whole.", and many of the system differences will be hidden from the software
OK, so this may sound all mysterious, but you’re probably very familiar with some very well-known OSes. Names like Windows, MacOS, Linux, Android, iOS: those are all operating systemsSoftware – or firmware – that handles the low-level aspects of a computer or IoT device. It gets direct access to all the resources. Software asks the OS for access to those resources.. Those OSes work on complex computer-like systems: laptops, smartphones, and the like.
I Need it NOW!
There are also less-recognizable OSes that may run on some IoT devices as well as, say, computer-controlled factory machinesIn our context, a machine is anything that isn't human (or living). That includes electronic equipment like computers and phones.. The problems with “regular” OSes are first that they’re really big, making them hard to fit in small devices, and the fact that, when you ask a “regular” OS for something, it will do it – you just don’t know when.
With some systems, you have to know when something’s going to happen. If you step on an electronic automotive brake (a thing mostly of the future), you want to know that the brake will activate within some time limit, not just “whenever I get to it.” These are called real-time constraints, and some of them are super serious – so-called hard real-time constraints, while others are important without being as critical.
For these kinds of systems, there are smaller real-time operating systemsAn OS where various tasks can be guaranteed to be completed within a specific timeframe., or RTOSes. These aren’t ones that you will likely have heard of, but they likely lurk within many of the devices you use. And they may be a good choice for IoT devices, depending on what their job is.
Stacks
There’s other software installed in IoT systems that may or may not be considered part of the OS. An important example is the software needed for communication. That software is stacked on top of – or within – the basic operating system, and you’ll often hear it referred to as a “software stackRelated to communications: A way of organizing parts of a complicated process (like communications) so that any task relies on tasks below it and feeds the tasks above it. Related to computing: A place in memory where you store “where was I?” information when you go from, say, one function into another. Before starting a new function, you store where you were in the old one so that, when the new function ends and you’re back in the old one, you can figure out where you were and continue on..” The benefit of this is that the main software doesn’t have to understand the details of how WiFiA common type of wireless network used to connect computers and phones to each other and the internet. or BlueTooth or whatever works; it just tells the stack that it wants to open a connectionThis refers to some kind of electrical connection. It might be through a network cable, a cable connection, a wireless connection, or a phone - just to name some options. The connection might be to the internet or to some other local device. and send some messages. The stack takes care of the details.
All of this is intended to make software more flexible. There are lots of programs that might run on these systems, although IoT devices are typically intended to do just a few things. Even so, this allows a few designers to spend their efforts on getting the OS and the various stacks right. Then the many developers of the higher-level software don’t have to worry about any of that, and they can move their code from one system to another with far fewer changes.
When You Have No Room for an OS…
Now… some systems are so timing-sensitive or so lacking in memory that they don’t have room or time for any OS, no matter how small. So you can have a system with no OS at all; it just makes writing the software much more challenging and error-prone. Such systems are sometimes called bare-metal systems, since the software directly touches the “bare metalDescribes a system that has no OS. Software runs directly on the hardware.” of the hardwareIn this context, "hardware" refers to functions in an IoT device that are built into a silicon chip or some other dedicated component. It's distinct from "software," which refers to instructions running on a processor. with no “cushion” of any kind. Really small IoT devices might work this way as well. (No, they’re not really touching metal.)
By the way, much of this OS and stack stuff makes up what we called the firmwareSoftware that is stored on a device itself. Regular computers have very little firmware, since software mostly comes from a hard drive or some other storage. But on IoT devices, much of the software may be firmware. some time ago. In computers, software programs aren’t considered firmware because they can be loaded or unloaded. In IoT devices, the software is fixed in the system (you can’t load a different program, for example), so it’s also part of the firmware.
Leave a Reply