PC running software without OS - Page 1
Forum section: electronics / general

author: Circlotron
author_rank: Super Contributor
timestamp: March 08, 2018, 01:54:37 am
content: Does anyone know of any PC software that would boot into itself without a separate operating system? Would probably have to be machine-specific but the idea is to get the absolute maximum performance from the hardware without the overhead of an OS limiting what you can do, slowing things down and generally getting in the way. Possibly similar to late '70s arcade game machines but on a larger scale.

author: Ampera
author_rank: Super Contributor
timestamp: March 08, 2018, 02:14:13 am
content: Of course this exists, and for most intents and purposes, this is effectively how many programs ran on MS-DOS, with DOS just being effectively TSR (Terminated, but Staying (memory) Resident). There were also PC booter programs, the most notable ones to come to mind being PC-MAN and I believe Paratrooper, but there are reasons why it's not done today.1. Nobody knows how to anymore. It's a GREAT level of complication to get something like this working, and while there are people who indeed still do this to some degree, they rarely start from scratch.2. You can't multitask without other programs to multitask with. Modern workloads rely on being able to switch between programs. If you can't do that, it's useless to many people.3. It's pointless. The overhead modern operating systems put in place, combined with things like many modern high performance applications being resigned to the GPU, and the fact that CPUs aren't harping over every instruction anymore, it just doesn't make sense to put so much extra effort into what may even end up not being a performance gain at all, due to the MASSIVE number of memory management and task management optimizations in modern kernels like Linux, Unix, and NT. It's just not worth it.Besides this, this is how many microcontrollers run, especially when you use something like C or ASM. The code is just plopped onto the CPU, and ran like that, as an OS is normally a bit overkill for the task at hand.

author: j_hallows
author_rank: Newbie
timestamp: March 08, 2018, 02:41:24 am
content: When you say PC, I assume X86 architecture. You want some sort of romable code. Check out Paradigm C++ (http://www.paradigmtools.com/). There were other tools and I believe GCC can compile romable code.

author: IanB
author_rank: Super Contributor
timestamp: March 08, 2018, 02:50:22 am
content: Quote from: Circlotron on March 08, 2018, 01:54:37 amThe simplest answer to your question is any flavour of DOS. Find some version of DOS, free or commercial, boot into it, and you own the machine. Any program you run under DOS has unrestricted access to the hardware with no impediments.If you really want to go hardcore, find the source code for a public/open source version of DOS or other similar program like CP/M, modify it and build your own thing that boots up directly from disk.Unfortunately, you will have a really hard time getting the maximum performance out of the hardware if you do this since you won't have all the special optimized drivers for the graphics card and disk drives.

author: Circlotron
author_rank: Super Contributor
timestamp: March 08, 2018, 03:00:25 am
content: I was just thinking of the whole pc behaving like a super duty microcontroller. I haven’t got an application, just a thought experiment. I didn’t think that DOS quite worked that way. I thought the program often told DOS to execute this or that interrupt or write to the disk or whatever and DOS handled all the dirty work. The program just did high level stuff and DOS translated it to the nitty gritty of what sector to read or what pixel to write.

author: IanB
author_rank: Super Contributor
timestamp: March 08, 2018, 03:59:17 am
content: Quote from: Circlotron on March 08, 2018, 03:00:25 amNo, it's not that way at all. DOS is able to load your program into memory and start it running. Then while your program is running DOS provides service calls that you can use for convenience if you wish. However, you don't have to use the DOS service calls (or even the BIOS calls) if you don't want to. Other than the BIOS, DOS provides no hardware abstraction layer. Your program runs in real mode (not protected mode) and all of the hardware is accessible at the register level. Your program can do what it likes.Of course normal, well-behaved DOS programs obey the rules and work cooperatively with the system. But they really don't have to.The lack of restrictions is how programs like DESQview were able to do really clever stuff.

author: hendorog
author_rank: Super Contributor
timestamp: March 08, 2018, 04:02:00 am
content: There was a version of Java which could run on the bare metal. But I think it got killed by Oracle.The concept has some merit, particularly in the VM space, where one (Server) application runs on one VM. The OS adds little or no value, and is just another thing that has to be deployed and configured.A VM presents standard hardware to the guest so the driver problem is not as difficult as it would be with real hardware.

author: daybyter
author_rank: Frequent Contributor
timestamp: March 08, 2018, 04:04:08 am
content: Back in the 8088 days, there were bootable games.Today you might find similar concepts in the fpga area. In fact I'm working on a bootloader at the moment. It is great fun on the one hand, but slow progress on the other.

author: CatalinaWOW
author_rank: Super Contributor
timestamp: March 08, 2018, 04:07:39 am
content: The only tighter you can get than DOS is to eliminate the unused functions. Perhaps file io. Or serial ports or whatever. The difference wouldn't be worth the effort, but if you were really motivated I believe that source code for DOS clones is available.

author: IanB
author_rank: Super Contributor
timestamp: March 08, 2018, 04:07:53 am
content: A further thought about the microcontroller concept. Get hold of an old PC from simpler times, something with serial and parallel ports, an ISA bus, and some suitable I/O cards, then install DOS and a C compiler from the same era, and yes, you can treat it like a giant microcontroller with a native development environment. You can write programs that address the hardware natively and do low level I/O. You can directly program and use hardware interrupts to help.

author: james_s
author_rank: Super Contributor
timestamp: March 08, 2018, 04:10:01 am
content: Bootable games were somewhat common in the PC/XT days, and far more common on slightly earlier 8-bit computers but the problem with anything like that is it has to be tailored to the exact hardware it's running on.Classic arcade games are a different sort of thing entirely, they used dedicated hardware rather than a general purpose computer. The program code and graphic objects are stored in ROM addressed by the CPU and video hardware.

author: Circlotron
author_rank: Super Contributor
timestamp: March 08, 2018, 06:12:42 am
content: Is there nowadays a 32 bit DOS that in particular uses a flat memory space?

author: @rt
author_rank: Super Contributor
timestamp: March 08, 2018, 08:55:49 am
content: I’d have imagined that every Windows installer has to first boot a program that isn’t an OS,albeit low res graphics and maybe beeps for sound, but it occurs to me that every PC clone has some compatible mode that can run an OS installer.

author: Ampera
author_rank: Super Contributor
timestamp: March 08, 2018, 09:31:29 am
content: Quote from: @rt on March 08, 2018, 08:55:49 amUntil, I believe, Vista, Windows Setup started up in what I think was a special DOS environment that loaded drivers and prepared to launch the NT Kernel. This is still an operating system as it still provides base disk functionality as well as the ability to load drivers, although the question "what is an operating system", may be blurred here. Nowadays, an OS called Windows PE (Preinstallation Environment) which is effectively a stripped down NT kernel, similar to how some POSIX operating systems run installers. It loads drivers, deals with drives, and installs Windows, after which it reboots into the full installed NT Kernel.

author: Ash
author_rank: Regular Contributor
timestamp: March 08, 2018, 09:56:35 am
content: Hi,There are a number of "bare metal" systems for different programming languages. Most of them are designed at the moment to target a virtual machine, but conceptually you would just need to implement your own driver level code for other hardware.The idea being that when you want to run a workload that does only one thing, you don't need a full operating system to do traditional things like separating applications, memory management, etc. I'm thinking things like web servers, caches, micro-services. A lot of this is currently done in containerised environments like docker as well. Just another approach I guess.Here are two that I know of:https://www.gocosmos.org/- Cosmos - C# operating systemhttp://www.includeos.org/- a C++ "#include <os>"Ash.

author: Zero999
author_rank: Super Contributor
timestamp: March 08, 2018, 10:40:59 am
content: Quote from: Circlotron on March 08, 2018, 06:12:42 amYes.DOS + a DOS extender. The main program is run in 32-bit protective mode, switching back to 16-bit mode, when a DOS call is made. This does involve some overhead, but is negligible for things such as disk access, as the hard drive is the biggest bottleneck. This was very popular for later DOS games.FreeDOS-32. A 32-bit protective mode DOS. It appears to be incomplete and no longer developed though.http://freedos-32.sourceforge.net/

author: capt bullshot
author_rank: Super Contributor
timestamp: March 08, 2018, 10:46:33 am
content: In former times I did such things on a 486 based hardware:For ease of use, the machine booted into MS-DOS (just to not to have to cope with all the BIOS / low level initialization stuff)), then ran a single program (using the Watcom 32bit extender) that never returned and never made any calls to the underlying MS-DOS / BIOS.

author: TerraHertz
author_rank: Super Contributor
timestamp: March 08, 2018, 11:04:11 am
content: The problem is, good luck getting info on how to configure and drive the hardware in a recent PC. The available driver code is all designed to run in a Windows environment, or Linux. With DOS you're going to be stuck with old PCs.

author: Ampera
author_rank: Super Contributor
timestamp: March 08, 2018, 11:06:43 am
content: Quote from: TerraHertz on March 08, 2018, 11:04:11 amGetting things like video is never going to be 100%, but things like USB, hard drive access, and even video to a large degree is all possible using a bunch of BIOS calls.

author: senso
author_rank: Frequent Contributor
timestamp: March 08, 2018, 11:48:54 am
content: What kind of usage do you expect to get out of such a system?Also, what kind of hardware are you running?Windows or linux never got in my path for max performance out of my hardware, I'm running ancient parts considered to the current gen, but my Haswell i7 laptops can chew throw anything that I throw at them...Running a bare metal "OS", would let me print on a console and not really do any real world work.Are you intending to develop software to make such a thing usable?

author: T3sl4co1l
author_rank: Super Contributor
timestamp: March 08, 2018, 12:32:13 pm
content: You only need DOS to do disk things. It's a Disk Operating System, obviously enough.If you don't need a file system, you can write your program or bootstrap into sector 0 of the disk, and go from there. You are still using another operating system, the BIOS, in this case. Typically int, uh... 13h for disk access (read sector and such)? The BIOS reads the boot sector into RAM at 0070:0000h, checks for validity, then jumps into it. From there, you need to read more sectors (if 512 bytes is not enough) into whatever memory you like.If you want bare bare metal, you have to put your program on a ROM on an expansion card, and have it mapped to a suitable location (usually 8k at C8000h or so; there's a map of usable locations). The CPU still starts in the system BIOS, but it jumps into your ROM during initialization, and everything is yours at that point, no disks needed.If you well and truly want everything to yourself, you must replace the system ROM, which might not always be doable (though it's almost always EPROM or Flash in a socket, which is nice). In that case, the CPU resets to F000:FFF0h or something like that, and the rest is yours. Just don't forget to initialize the DMA and PIT, or the RAM will be very forgetful. And set the graphics registers to something sensible (or jump into the video BIOS to do it for you), and the PIC and so on...Classic IBM PC hardware is quite well documented, but proprietary devices are not. For them, you need drivers, which you either need some way to access, or a compatible OS to run them in. In the classic days, this is precisely what they did -- the driver was included on-chip, initialized during boot. That's how the BIOS knows about an installed hard drive card, for instance, and how to use it. Since the 90s, software drivers for interfacing to the OS have been necessary, and you will have a harder and harder time using those on a "bare" system without constructing something very much equivalent to an OS in the first place.Also, practically anything since the early to mid 90s will be 32 bit protected mode (or more), including device buffers mapped to upper (32 bit) memory blocks. Also, PnP is a thing, including enumerating all the buses and bridges, northbridge and southbridge controllers, even just the RAM...Tim

author: Dr. Photon
author_rank: Contributor
timestamp: March 08, 2018, 04:42:07 pm
content: I thought that the old memory testing application MemTest86 ran as close to bare metal (didn't start from DOS) as it could?

author: picitup
author_rank: Regular Contributor
timestamp: March 08, 2018, 04:58:51 pm
content: Ahh... Int 21 under dos and pip under CP/M. Yes it's true, I'm old

author: Ampera
author_rank: Super Contributor
timestamp: March 08, 2018, 05:49:13 pm
content: Quote from: picitup on March 08, 2018, 04:58:51 pmI'm young and still program using it.

author: mdijkens
author_rank: Regular Contributor
timestamp: March 08, 2018, 09:24:33 pm
content: I think for absolute maximum performance, modern PC's do NEED an OS !Of course the OS adds overhead, but it also makes optimal use of all the advanced cpu/gpu and chipset features.In the early days I've written low level assembler on the 8086 and 80286 architecture. It made sense for very specific softwareBut nowadays I doubt you get half the performance compared to an optimized and well tuned Windows or Linux OS

author: T3sl4co1l
author_rank: Super Contributor
timestamp: March 08, 2018, 09:45:09 pm
content: Early x86 were also tuned more for assembler than C, and C compilers sucked (and BASIC was a joke of myriad subroutines; but a scripting language, pasted into an EXE if you had the compiler). Both are quite good together, and modern (post-386) optimization is all about managing caches.OS overhead is quite small for the most part. Heck, even if it were a mere 1%, that's still a huge amount of computation available.Tim

author: SirAlucard
author_rank: Regular Contributor
timestamp: March 09, 2018, 01:20:33 am
content: There is bare metal programming, however anything you'd want to do with it you'd have to program in your own drivers and what have you. It's by no means an easy way to get speed. I myself have tried looking into ways of speeding up boot times with a Raspberry pi, trying to look for the thinnest OS I can find. The problem with that, is it doesn't come with some of the bare essentials you need. So while you could do it without an OS, or at the very least a bare bones OS. Sometimes it's just better to work with what you have and try to trim the fat where you can.

author: james_s
author_rank: Super Contributor
timestamp: March 09, 2018, 02:05:05 am
content: I wouldn't say BASIC sucked. It was designed as a very easy to use beginners programming language that was also quite versatile. For what it was intended to do it did a good job, I suspect quite a large percentage of us got our first taste of programming by using BASIC.

author: SirAlucard
author_rank: Regular Contributor
timestamp: March 09, 2018, 07:26:10 am
content: Quote from: james_s on March 09, 2018, 02:05:05 amDoes TI-Basic count? lol My very first jaunt in programming was doing basic on a TI-83 back in Jr.high. I programmed a couple of programs to have easier access to equations, as well as do a few calculations for me based on some RPGs I was playing at the time.