{"id":49422872,"url":"https://github.com/nktkt/zig-kernel","last_synced_at":"2026-04-29T07:10:01.960Z","repository":{"id":349095419,"uuid":"1201042302","full_name":"nktkt/zig-kernel","owner":"nktkt","description":"x86 OS kernel in Zig — 50,000 LOC, 136 files, 110+ subsystems. GUI, TCP/IP, FAT16/ext2, fork/exec, BSD sockets, firewall, CFS scheduler, 80+ shell commands. From 150 lines to hobby OS.","archived":false,"fork":false,"pushed_at":"2026-04-11T07:11:09.000Z","size":933,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2026-04-11T09:18:35.100Z","etag":null,"topics":["bare-metal","kernel","operating-system","os","os-development","x86","zig"],"latest_commit_sha":null,"homepage":null,"language":"Zig","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nktkt.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-04-04T06:06:51.000Z","updated_at":"2026-04-11T07:11:12.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/nktkt/zig-kernel","commit_stats":null,"previous_names":["nktkt/zig-kernel"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/nktkt/zig-kernel","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nktkt%2Fzig-kernel","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nktkt%2Fzig-kernel/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nktkt%2Fzig-kernel/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nktkt%2Fzig-kernel/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nktkt","download_url":"https://codeload.github.com/nktkt/zig-kernel/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nktkt%2Fzig-kernel/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32414658,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-29T06:29:02.080Z","status":"ssl_error","status_checked_at":"2026-04-29T06:29:00.631Z","response_time":110,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bare-metal","kernel","operating-system","os","os-development","x86","zig"],"created_at":"2026-04-29T07:09:58.016Z","updated_at":"2026-04-29T07:10:01.947Z","avatar_url":"https://github.com/nktkt.png","language":"Zig","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Zig Kernel\n\nAn x86 operating system kernel written from scratch in Zig. 50,000+ LOC across 136 source files with 110+ subsystems — from boot to GUI, networking, filesystems, and a shell with 80+ commands.\n\nStarted as 150 lines. Now a hobby OS.\n\n## Quick Start\n\n```bash\nzig build\nqemu-system-i386 -kernel zig-out/bin/kernel \\\n  -device e1000,netdev=n0 -netdev user,id=n0 \\\n  -drive file=disk.img,format=raw,if=ide\n```\n\n## What Works (verified in QEMU)\n\n- **Boot** → 20+ subsystems initialize OK\n- **`ping 10.0.2.2`** → `Reply from 10.0.2.2: time=1ms`\n- **`fork`** → Parent/child process creation, wait, exit code 42\n- **`gui`** → VGA Mode 13h graphics with colored rectangles and text\n- **`mkdir test \u0026\u0026 cd test \u0026\u0026 write hello.txt hi \u0026\u0026 cat hello.txt`** → Hierarchical filesystem\n- **`su guest`** → `guest@zig-os:/$` → `su root` → `root@zig-os:/#`\n- **`Ctrl+C`** → SIGINT to running processes\n- **`sysinfo`** → neofetch-style system overview\n- **FAT16 disk** → `dwrite file.txt content` writes to real disk\n\n## Features\n\n### Core (v0.1–v0.5)\n- Multiboot1 boot, GDT, IDT, PIC, TSS\n- Preemptive round-robin scheduler (1kHz PIT)\n- fork/exec/wait/exit with zombie reaping\n- Signals: SIGKILL, SIGTERM, SIGINT (Ctrl+C)\n- 9 syscalls via INT 0x80\n- Per-process page directory (CR3 switching)\n\n### Memory\n- Bitmap PMM (4KB pages, 4GB addressable)\n- First-fit heap, slab allocator (6 caches), buddy allocator (7 orders)\n- Pool allocator (8 fixed sizes), LRU cache\n- Virtual memory areas (VMA) per process\n\n### Filesystems\n- **ramfs** — Inode-based with directory hierarchy\n- **FAT16** — Read/write on ATA disk\n- **FAT32** — Read-only with LFN support\n- **ext2** — Read/write with bitmap allocation\n- **tmpfs** — PMM-backed temporary filesystem\n- **devfs** — /dev/null, zero, random, console, serial, mem\n- **procfs** — /proc/version, meminfo, cpuinfo, mounts\n- VFS layer, mount points, Unix permissions, path utilities\n\n### Networking\n- Intel E1000 NIC driver (PCI MMIO, DMA)\n- Ethernet frames, VLAN (802.1Q)\n- ARP (cache with aging), IPv4 (fragmentation/reassembly), IPv6 basics\n- ICMP ping, TCP (retransmit, congestion control, TIME_WAIT)\n- UDP sockets, BSD socket API (16 sockets)\n- DNS, DHCP, NTP, TFTP, HTTP/1.0, Telnet\n- Firewall (32 rules), routing table (16 entries), network stats\n\n### GUI\n- VGA Mode 13h (320x200, 256 colors)\n- Canvas: line, circle, ellipse, triangle, bezier, flood fill\n- Window manager: 8 windows, z-order compositing, title bars\n- Widgets: label, button, checkbox, progress bar, text input\n- Event queue, 3 visual themes, VGA palette programming\n- 8x16 + 8x8 bitmap fonts with bold/outline rendering\n- 4 virtual consoles with scrollback\n\n### Drivers\n- PCI enumeration + device database (50+ devices)\n- ATA PIO (LBA28) + MBR partition parsing\n- PS/2 keyboard (shift, Ctrl, arrow keys, F1-F3)\n- PS/2 mouse (IRQ12, position tracking)\n- VGA text (VT100 escape sequences) + framebuffer\n- Serial (COM1, 38400 baud)\n- USB UHCI + VirtIO detection\n\n### Process Management\n- CFS-like scheduler (vruntime, nice values -20..19)\n- Kernel threads, semaphores, read-write locks, futex\n- Message queues, shared memory, event flags\n- Process capabilities (12 Linux-style caps)\n- 32 POSIX signals with handler registration\n- Pseudo-terminals (4 PTY pairs)\n\n### Security\n- Multi-user: root/guest, su, login, UID/GID\n- File permissions (rwxrwxrwx + setuid/setgid/sticky)\n- Process capabilities (CAP_SYS_ADMIN, CAP_NET_RAW, etc.)\n- Packet filter firewall\n\n### Libraries\n- String (strlen, strcmp, atoi, itoa, contains)\n- Math (sqrt, pow, gcd, prime, fixed-point, sine table)\n- Regex (NFA, char classes, quantifiers)\n- JSON parser, Base64, UTF-8, CRC32/FNV-1a\n- RLE + LZ77 compression, color manipulation\n- Sorting (6 algorithms), binary search\n- Ring buffer, bitmap, linked list, priority queue, hash table, memory pool\n\n### Applications\n- **Shell** — 80+ commands, history (↑↓), aliases, tab completion, scripting\n- **Editor** — ed-like (insert, delete, substitute, save/load)\n- **Games** — Number guessing + snake\n- **Benchmarks** — 8 kernel benchmarks with timing\n- **Init scripts** — Boot automation\n\n### Debug \u0026 Profiling\n- Panic with BSOD + register dump + stack trace\n- ISR 0-19 with page fault details (read/write/user/kernel)\n- Kernel symbol table with address resolution\n- Function profiler + PC sampling histogram\n- Watchdog timer, kernel logging (5 levels)\n- In-kernel test suite (8 tests)\n\n## Architecture\n\n```\n136 source files, 50,001 LOC\n\nsrc/\n├── Boot \u0026 Core         kernel.zig, gdt.zig, idt.zig, tss.zig, init.zig\n├── Memory              pmm.zig, heap.zig, slab.zig, buddy.zig, pool_alloc.zig,\n│                       paging.zig, vmm.zig, vma.zig, mmu.zig, cache.zig\n├── Process             task.zig, scheduler_rr.zig, scheduler_cfs.zig,\n│                       kthread.zig, signal_handler.zig, workqueue.zig\n├── Syscall             syscall.zig, syscall_table.zig, posix.zig, errno.zig, ioctl.zig\n├── Filesystem          ramfs.zig, fat16.zig, fat32.zig, ext2.zig, tmpfs.zig,\n│                       devfs.zig, procfs.zig, vfs.zig, mount.zig, path.zig, permission.zig\n├── Networking          e1000.zig, net.zig, ethernet.zig, ip.zig, ipv6.zig,\n│                       tcp.zig, udp.zig, icmp.zig, arp_cache.zig,\n│                       dns.zig, dhcp.zig, ntp.zig, tftp.zig, http.zig, telnet.zig,\n│                       socket_api.zig, firewall.zig, routing.zig, net_util.zig, netstat.zig\n├── Drivers             pci.zig, pci_db.zig, ata.zig, blkdev.zig, disk_util.zig,\n│                       keyboard.zig, mouse.zig, serial.zig, uhci.zig, virtio.zig\n├── Display             vga.zig, framebuf.zig, canvas.zig, font.zig,\n│                       window.zig, widget.zig, event.zig, theme.zig, vt.zig\n├── IPC \u0026 Sync          pipe.zig, pty.zig, ipc.zig, semaphore.zig, rwlock.zig,\n│                       futex.zig, kobject.zig\n├── Security            user.zig, capability.zig, acpi.zig, smp.zig, power.zig\n├── Libraries           string.zig, math.zig, fmt.zig, regex.zig, json.zig,\n│                       base64.zig, utf8.zig, compress.zig, crypto.zig, color.zig,\n│                       sort.zig, ringbuf.zig, bitmap.zig, list.zig, queue.zig,\n│                       hashtable.zig, mempool.zig\n├── Applications        shell.zig, shell_ext.zig, editor.zig, game.zig, ksh.zig,\n│                       coreutils.zig, bench.zig, init_script.zig\n├── Debug               isr.zig, panic_screen.zig, debug.zig, profiler.zig,\n│                       watchdog.zig, ksym.zig, log.zig, test_suite.zig\n└── Config              env.zig, config.zig, sysctl.zig, version.zig,\n                        timer.zig, time.zig, cmos.zig, rtc.zig,\n                        elf.zig, elf_parser.zig, tar.zig, archive.zig\n\nbuild.zig              Zig build config (x86 freestanding, SSE/AVX disabled)\nlinker.ld              Linker script (1MB base, 16KB stack)\nROADMAP.md             5-milestone roadmap to Linux-scale\n```\n\n## Prerequisites\n\n- [Zig](https://ziglang.org/) 0.15+\n- [QEMU](https://www.qemu.org/) (`qemu-system-i386`)\n- Optional: `mtools` for FAT16 disk images\n\n## Version History\n\n| Version | LOC | Highlights |\n|---------|-----|-----------|\n| v0.1 | 150 | Boot + VGA |\n| v0.2 | 518 | GDT, IDT, keyboard, PMM |\n| v0.3 | 964 | Shell, timer, heap |\n| v0.4 | 1,220 | Paging, serial, RTC |\n| v0.5 | 1,719 | User space, syscalls, multitasking |\n| v0.6 | 3,236 | PCI, ATA, FAT16, E1000, networking |\n| v0.7 | 4,724 | VFS, TCP/UDP, multi-user, ELF |\n| v0.8 | 5,218 | fork/wait/signals, VMM |\n| v0.9 | 5,647 | Hierarchical FS, VT100 |\n| v1.0 | 7,582 | ACPI, SMP, DNS, DHCP, ext2, USB |\n| v1.1 | 10,391 | Command history, env vars, sysinfo |\n| v1.2 | 30,001 | GUI, canvas, CFS, 25 new modules |\n| **v1.3** | **50,001** | **BSD sockets, firewall, IPC, profiler, 110+ subsystems** |\n\nSee [ROADMAP.md](ROADMAP.md) for the path to Linux-scale (MS3: 100K, MS4: 500K, MS5: 36M).\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnktkt%2Fzig-kernel","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnktkt%2Fzig-kernel","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnktkt%2Fzig-kernel/lists"}