Skip to the content.

simulOS – simulated Operating System

YouTube Demo Link

Other READMEs

Description

This is a program that tries to simulate Linux operating system by imitating several features. Namely, they are shell, filesystem, command handling unit, and core/user-defined programs.


Running the program

    git clone https://github.com/oyatillonewuu/simulOS
    cd simulOS
    make // if you have it on your system
    ./simulos

If you don’t have make utility on your system, run the program typically and ensure that all source (*.cpp) files are compiled.

Try apps command to get the list of available apps (commands).


System components & workflow

Except programs part, all parts are defined as classes, with not mentioned OS class aggregating them. They are organized in a directories resembling modules.

OS class serves to instantiate FileSytem and Shell.


Shell

Shell is a class/sub-program that allows a user to interact with the system, and run core/usr(user-defined) programs. As user writes a command and hits the enter, Shell implicitly redirects the control to CommandHandler class of command unit.


Command Handling

CommandHandler parses the user input and tries to match a command from the commands of existing programs. Any matching command found, it will execute it. The control is returned back to Shell.


Extensibility feature

simulOS has been designed to provide extensibility before compilation, if not on runtime. This means that others can include their programs with their corresponding commands. This design is made possible by creating an interface that makes core/user-defined program commands plug-in-able.

The Interface for Extending

The interface, Command, is provided by the command unit. Beyond giving extensibility, it also provides an access to FileSystem resources by passing Shell which has the main FileSytem resources which are root directory and current directory.

To use the extensibility feature, a developer creates a class for the command of their app. This class inherits from Command abstract (or interface in this context) class and passes necessary arguments like the keyword of a command, its number of arguments, and the description. The virtual function operate has to be overriden, or adjusted. Then a developer has two choices: either write their program in this command class or write another class for the program logic and make it callable from the command they defined. This depends on how large is their program.

After the program command and logic is implemented, the developer has to registerCommand function provided by CommandRegistry class – which loads core/user-defined programs before the main program runs.


About FileSystem and its rules

FileSystem class organizes files and directories and their management in the system. Files and directories are the same except for some differences like files have content while directories can have children. Also, currently, there is no support for file extensions and, thus, including dots and slashes is strictly disallowed. So the creation of files/directories violating the naming is automatically disregarded.


Design

Operation Execution Success & Error Handling

All main system operations use integer-based code to indicate different errors. Here are primary ones:

    0 -- success
    -1 -- error
    -2 -- shutdown/exit system/Shell signal


Limitations








Contributors

Apologies for contributors as I may not have included all contributions correctly. Due to memory error.

Special thanks: To @hasan-mavlonov who brought the idea by @loga4m into the basis/near-form for the current design.