MiniOS is a mini operating system simulator. I built it to understand how operating systems actually work instead of just reading about them in theory. It has process management, file systems, user authentication, and logging.
Logger: Keeps a record of everything that happens in the system. Every action gets a level (INFO, WARN, ERROR, DEBUG) and a message. Pretty straightforward.
ProcessManager: Creates and manages processes. Uses a simple Round Robin algorithm: each process gets a turn in the queue, runs, then goes back to the end. Fair scheduling, basically.
FileSystem: You can create, read, write, and delete files. Files are stored in a dictionary with content, owner, and creation time. Only the owner or root can change or delete files. Had to enforce this to avoid breaking permissions.
UserManager: Handles user login and passwords. Root user exists by default and has special permissions. Only the root can create users or view logs.
Shell: The command interface. Has 16 commands that let you actually interact with the system. Parses commands, handles quoted arguments, and sends them to the right handler.
MiniOS: Ties everything together. Boots the system, manages who's logged in, handles shutdown.
python miniOS.pyLogin:
Login username (enter for root): root
Password: root
Then use commands:
whoami- Shows current usercreate file.txt Hello- Make a new filels- List filesread file.txt- Read file contentwrite file.txt NewText- Update filedelete file.txt- Remove fileps- List processesrun bash ls- Create processkill 1- Stop a processadduser john pass123- Add user (root only)logs- View logs (root only)help- See all commandsshutdown- Exit
- User login with password verification
- File creation/reading/writing/deletion with ownership
- Process creation and simple Round Robin scheduling
- Root and regular user permission levels
- System logging for everything
- Terminal with command parsing
- Error handling that doesn't crash
- Everything runs in memory, so it doesn't save anything after you shut down
The hard parts were:
-
Sharing the Logger across everything: All components needed access to the same logger so logs didn't get scattered everywhere. Had to think about how to pass it around properly.
-
The scheduler: Implementing Round Robin sounds simple on paper. You take from the front, run it, and put it at the back. But handling process termination, checking if a process still exists, and keeping the queue in sync.
-
File permissions: Keeping track of who owns what and stopping users from accessing files they shouldn't. Had to check ownership every single time someone tried to modify a file.
-
Command parsing: Handling quoted strings like
create "my file.txt" "hello world"where spaces shouldn't split the arguments. The parser had to track whether you're inside quotes or not. -
Error handling: Making sure that when something goes wrong, the system tells the user what happened and keeps running.
-
miniOS.py- Main code -
test_miniOS.py- Tests