Why We Need Operating System?

  •  40 views
  • I made my own Gameboy emulator last year. Recently when I show it off to my friend, he asked me a thought-provoking question

    that I never came up with but should have: Does it need a operating system to run the game?

    Certainly, I knew the answer, because I had provide sufficient implement that a whole successful game playthrough needs, and I definitely had never heard of this item during the process. However, I, as a so-called programmer, who had already heard of the word “operating systems”, when heard the question, awkwardly asked myself, “But why?”

    I just found myself having no idea what does actually a operating system do.

    I mean, take a gander at the processing flow graph of Gameboy:

    When you insert a cartridge into the Gameboy and have the Gameboy’s power on, the CPU, central processing unit, will initialize its inner state, such as numbers of registers. A special register called PC, or process counter, will be read by the BUS and the corresponding instruction that the address stores indicates in the cartridge will be transferred by the bus to the CPU, and CPU, execute the instructions, such as adding numbers, setting states, or write to the APU, audio processing unit, or the PPU, pixel processing unit, through the bus, back and forth, and as a result, you can see the dynamic pixels that is displayed on its screen and enjoy the classic 8-bit music from its speakers.

    A Gameboy’s game doesn’t need a operating system, it just operates the devices itself.

    After I finished some readings, I found the three key features that a operating system provides with:

    1. Concurrency;

    2. Persistency;

    3. Virtualization.

    Concurrency

    Concurrency means you can run multiple tasks at the same “time” (time piece) while not bothering others. Operating system has a smart algorithm to dispatch and execute tasks.

    Concurrency isn’t necessary for games running on the Gameboy as there is only one game running on it at the same time, and single task processing is just enough for the complexity of the game.

    Persistency

    Persistency means ability to persistently store data easily, while the integrity and security is guaranteed by the operating systems. And a file system is also used by the operating system for the orchestration of files.

    Persistency is vital for the saving data of games. But it’s relatively simple: it’s just a single bunch of data and only one process will do IO operations to it. So it’s also not necessary.

    Virtualization

    Operating systems virtualizes the hardware resource, such as memory, calculating power of CPU, so the processes running on the device can run on their own quota of resources, while thinking they have occupied all resources.

    As we’ve mentioned above, there is only one process that has occupied all the resouces. No resources are to be shared so nothing will be interfered with.

    And now I’ve figured out why Gameboy doesn’t need a operating systems as it doesn’t need the basic conveniences that are provided by OS above.

    Leave a Reply

    Your email address will not be published. Required fields are marked *