Sadly, assuming the OS is actual OS, and not a black screen with nothing that does nothing. It is impossible.
In fact, it is "impossible" to make a complex software guaranteed to be bug free.
Testing and Code Coverage
Basically, you'll have too many possible path to test them all features, and the use several features in a specific order, to ensure at 100% that your software is bug free.
Of course, the idea is to get the closest a you can to 100%. And that is why, you have in software development, the 'demo curse', when you work on a software, you deeply tested it times and times again for the important presentation that you have, and come to the presentation, it crashes on you. Of course, they are tricks to avoid this: several rehearsing, knowing where to click in which order of the demo you are doing, so that you always use the tested path that won't crash, and appear natural, for example. But anyway, that is off topic, it's just to say that as long as humans code, it is impossible, at least for now. You can be close, but not 100%.
Also, you have hardware failure rate. Consumer grade hardware are around 95% reliable. Servers and workstation are around 98%, and companies are paying a premium price to get that, as the manufacture selects the best chips and parts produced. They perform more extensive testing on them, and has additional features like ECC memory and other error correction systems.