Skip to content

prisect/smetana

Repository files navigation

Smetana OS

A scalable, production-grade operating system kernel written in C and Assembly for x86 architecture. Designed for scale-up with modern OS features.

Architecture

Smetana OS uses a hybrid microkernel/monolithic architecture for optimal performance and scalability:

Core Components

  • Memory Management

    • Physical Memory Manager (PMM) with bitmap-based page frame allocation
    • Virtual Memory Manager (VMM) with full paging support
    • Kernel heap allocator (kmalloc/kfree)
    • User-space memory protection via page tables
  • Process Management

    • Preemptive multitasking with round-robin scheduler
    • Process Control Blocks (PCBs) with full process state tracking
    • Process hierarchy (parent/child relationships)
    • Priority-based scheduling with time slices
    • Process states: READY, RUNNING, BLOCKED, SLEEPING, ZOMBIE
  • System Call Interface

    • POSIX-like syscall interface (int 0x80)
    • 23+ syscalls including: fork, exec, read, write, open, close, mmap, socket, etc.
    • User-kernel mode transitions with privilege separation
  • Driver Framework

    • Modular driver subsystem with device abstraction
    • Block and character device support
    • Device node management (/dev/*)
    • Standardized driver operations (open, close, read, write, ioctl)
  • Filesystem

    • Ext2 filesystem support (persistent storage)
    • VFS (Virtual Filesystem) layer for abstraction
    • In-memory filesystem for ramdisk
    • File descriptor management
  • Network Stack

    • Full TCP/IP stack implementation
    • Ethernet, IP, ICMP, UDP, TCP protocols
    • Socket API for network programming
    • RTL8139 Ethernet driver
  • Security

    • Protection rings (Ring 0 for kernel, Ring 3 for user)
    • Capability-based security model (POSIX capabilities)
    • Memory protection via page tables
    • System call permission checks
    • User/kernel-space separation

Boot Process

  1. Multiboot-compliant bootloader loads kernel
  2. GDT (Global Descriptor Table) setup
  3. IDT (Interrupt Descriptor Table) setup
  4. PMM initialization (physical memory detection)
  5. VMM initialization (paging enable)
  6. Process manager initialization
  7. Driver subsystem initialization
  8. Security subsystem initialization
  9. Network stack initialization
  10. Scheduler starts with test processes

Features

  • Multitasking: Preemptive multitasking with priority-based scheduler
  • Memory Management: Paging, virtual memory, heap allocation
  • Filesystem: Ext2 (persistent) and in-memory filesystems
  • Network: Full TCP/IP stack with socket API
  • Security: Protection rings, capabilities, memory protection
  • Drivers: Modular driver framework with device abstraction
  • Syscalls: POSIX-like system call interface
  • Shell: Command-line interface with 20+ commands

Requirements

sudo apt install make nasm gcc xorriso grub-common qemu-system-x86

Build & Run

# Build
make

# Run in QEMU
./controller.sh run
# or directly:
qemu-system-i386 -cdrom out/Smetana.iso -m 512M

Commands

Category Commands
System help, clear, reboot, shutdown, loadkeys
Files ls, cd, pwd, mkdir, touch, rm, cat
Info ps, meminfo, free, uptime, uname, date, time, cpuid
Memory malloc <size>
Network dhcp, ping <ip>, netinfo
Misc echo <text>

Project Structure

smetana/
├── src/                 # Kernel source code
│   ├── asm/            # Assembly files (entry, context switch, syscalls)
│   ├── programs/       # User programs
│   ├── pmm.c           # Physical Memory Manager
│   ├── vmm.c           # Virtual Memory Manager
│   ├── process.c       # Process management
│   ├── syscall.c       # System call handler
│   ├── driver.c        # Driver framework
│   ├── ext2.c          # Ext2 filesystem
│   ├── tcpip.c         # TCP/IP network stack
│   ├── security.c      # Security subsystem
│   └── ...
├── include/             # Header files
│   ├── pmm.h
│   ├── vmm.h
│   ├── process.h
│   ├── syscall.h
│   ├── driver.h
│   ├── ext2.h
│   ├── tcpip.h
│   └── security.h
├── config/              # Linker script and GRUB config
├── Makefile             # Build system
└── README.md            # This file

Scalability

Smetana OS is designed for scale-up with:

  • Modular architecture: Clear separation between subsystems
  • Driver framework: Easy addition of new hardware support
  • VFS layer: Support for multiple filesystems
  • Network stack: Full TCP/IP for distributed systems
  • Security model: Capability-based for fine-grained control
  • Memory management: Paging supports large address spaces

License

MIT License - Educational and commercial use encouraged.

About

An OS using the x86_64 architecture, in Assembly and C. Designed for performance and it's lightweight size.

Topics

Resources

License

Stars

3 stars

Watchers

1 watching

Forks

Contributors