Re: 10k lines of code?
I think there may be a confusion here because everyone is so used to systems designed to handle arbitrary workloads and diverse hardware configurations that it never really occurs to them that if you forego flexibility, systems can be MUCH smaller. The first large computer I ever worked with was the AN/FSQ-7 computer used in the SAGE Air Defense System. It was designed in the 1950s and was huge for the times -- 64K (That's K not M or G) of 32 bit words. Vacuum tubes,not transistors. Thousands of 6SN7 dual triode tubes. 6 uSec cycle time. i.e. 0.167Mhz clock. Somehow, it managed to process raw radar data from a dozen sites, track many dozens of aircraft, drive several dozen interactive display consoles, guide unmanned missiles, manage manned interceptions, talk to manual sites, and even communicate with adjacent sectors well enough to hand over tracked aircraft when they reached the edge of the sector. Even more amazing, it actually (mostly) worked.
How could it do all that on a computer roughly equivalent to an IBM PC with 256K of memory? Lovingly hand crafted code operating in fixed time slots with fixed time slots. Polled, not interrupt driven IO. No software data bus. My point, you can do a lot with very limited resource, if you don't use the ubiquitous modern system architectures and you forego flexibility.
Cheap? Heck no. It cost a fortune back then. And anything done similarly today is probably still going to cost a fortune. BUT, IF YOU WANT SECURE SOFTWARE AND DON'T REALLY NEED FLEXIBILITY, AND HAVE LOTS OF MONEY TO SPEND, you can possibly get pretty good results with a small, carefully curated, "There's only one way (at most) to do things" OS. Perfectly secure? I doubt it. But pretty good, maybe good enough, security? Maybe.