[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"project-75678":3},{"id":4,"name":5,"fullName":6,"owner":7,"repo":5,"description":8,"homepage":9,"htmlUrl":10,"language":11,"languages":10,"totalLinesOfCode":10,"stars":12,"forks":13,"watchers":14,"openIssues":15,"contributorsCount":16,"subscribersCount":16,"size":16,"stars1d":16,"stars7d":15,"stars30d":17,"stars90d":16,"forks30d":16,"starsTrendScore":16,"compositeScore":18,"rankGlobal":10,"rankLanguage":10,"license":19,"archived":20,"fork":20,"defaultBranch":21,"hasWiki":20,"hasPages":20,"topics":22,"createdAt":10,"pushedAt":10,"updatedAt":29,"readmeContent":30,"aiSummary":31,"trendingCount":16,"starSnapshotCount":16,"syncStatus":14,"lastSyncTime":32,"discoverSource":33},75678,"mazu","MazuNIX\u002Fmazu","MazuNIX","RTOS combining Linux rigor with Plan 9 simplicity, designed around SMP, real-time scheduling, and integrated networking.","",null,"C",114,23,2,1,0,68,4.14,"MIT License",false,"main",[23,24,25,26,27,28],"linux-like","networking","real-time-operating-system","risc-v64","rtos","smp","2026-06-12 02:03:35","# The Mazu Operating System\n\n`mazu` is a bare-metal RISC-V 64-bit hard RTOS that combines Linux kernel\ndiscipline with Plan 9 philosophy in a system small enough to read end to\nend. SMP correctness, hard real-time scheduling, and kernel-integrated\nnetworking are not bolted on after the fact; they shape every data\nstructure and code path from the start.\n\nUnlike RTOSes that treat networking as an optional middleware layer and\nSMP as a bolt-on configuration flag, Mazu takes the opposite position: a\nconnected embedded system needs bounded-latency scheduling, per-CPU\nexecution paths, and a TCP\u002FIP stack that respects both, all in the same\naddress space, all under the same lock discipline. The kernel serves REST\nAPIs and runs a web-based shell as ordinary preemptible tasks alongside\ndeadline-scheduled control work.\n\nTwo design lineages run through the codebase:\n- From Linux: subsystem modularity (initcall registration, irqchip\n  vtables, IRQ descriptor tables, waitqueues, lockdep), synchronization\n  primitives (priority-inheritance mutexes, futexes with PI and requeue,\n  counting semaphores with direct handover), buddy allocator, per-CPU\n  data via the `gp` register, and the convention that every subsystem is\n  SMP-safe or explicitly documented otherwise.\n- From Plan 9: the \"everything is a file\" control plane. Synthetic\n  filesystems (`\u002Fdev`, `\u002Fproc`, `\u002Fnet`) expose hardware, process state,\n  and network tables as readable files. No `ioctl`, no sysfs, no procfs\n  special-case parsers. System observability comes from\n  `cat \u002Fnet\u002Ftcp\u002Fstats`, not a dedicated monitoring daemon.\n\nWhat Mazu does not import from either lineage is equally deliberate: no\nloadable modules, no virtual memory isolation between tasks, no VFS page\ncache, no socket API. The kernel runs all tasks in a single shared page\ntable (identity-mapped kernel space, shared user mappings at fixed VAs)\nwith VMA-based access control, and the networking API is a direct\nfunction interface rather than a Berkeley sockets layer. Disk-backed SFS\nhas its own block buffer cache (`kernel\u002Ffs\u002Fbcache.c`); the synthetic and\nRAM filesystems are uncached because their data is either memory-resident\nor generated on demand.\n\nFor the detailed rationale behind these choices, see\n[docs\u002Fdesign.md](docs\u002Fdesign.md).\n\n## PSE51 framing\n\nMazu implements a bounded PSE51-oriented userspace core with deliberate\nfilesystem and multi-process supersets. PSE51 itself is a single-process,\nthreaded, no-filesystem profile; Mazu ships a real filesystem,\n`SYS_SPAWN` \u002F `SYS_WAIT`, and multiple PIDs by design, so the honest\ntop-level framing of the user-visible environment is closer to PSE52\n(Realtime Controller System Profile). The kernel-level primitives that\nback PSE51-facing syscalls (PI mutexes, condvars, semaphores, futexes,\nbarriers, rwlocks, message queues, POSIX timers) are already in place.\nPer-syscall conformance status, including which entries use a\nMazu-specific ABI shape rather than the exact POSIX shape, is tracked in\n[docs\u002Fpse51-matrix.md](docs\u002Fpse51-matrix.md).\n\n## Core capabilities\n\n- Hard-RT scheduling: mandatory kernel preemption, SMP per-CPU run\n  queues, bounded-quantum rotation among equal-priority threads, EDF\n  deadline scheduling with admission control, mixed-criticality\n  domains, load balancing, scheduling domains with budget enforcement.\n- SMP by design: per-hart state via `gp` register, per-CPU run queues\n  and merged deadline management, lockdep lock-ordering enforcement,\n  cache-line-aligned per-CPU structures.\n- Kernel-integrated networking: IPv4, TCP (Reno CC, SACK, RTT\n  estimation, connection pooling, per-IP flood limits), optional\n  UDP\u002FDHCP\u002FmDNS, outbound client connections, HTTP\u002F1.1 server with REST\n  endpoints, WebSocket, and SSE; all running as preemptible scheduler\n  tasks.\n- Plan 9-style VFS: synthetic `\u002Fdev`, `\u002Fproc`, `\u002Fnet` alongside a RAM\n  filesystem with optional writable and virtio-blk paths.\n- Linux-grade synchronization: PI mutexes with direct handover,\n  condition variables, counting semaphores, futexes\n  (WAIT \u002F WAKE \u002F CMP_REQUEUE \u002F LOCK_PI \u002F UNLOCK_PI).\n- Type-driven safety: length-prefixed fat strings (never\n  null-terminated), macro-generated result types,\n  read-only\u002Fread-write\u002Fappendable buffer types encoding mutability in\n  the type system.\n- Memory: buddy allocator for pages, pool allocators for fixed-size\n  objects, arena allocators for request-scoped temporaries, pluggable\n  allocator vtable.\n- Kernel-user isolation: W^X, VMA-based user-pointer containment\n  validation, per-process syscall allow-list, kernel-stack guard pages,\n  stack-protector canaries.\n- Debug and verification: lockdep, scheduler invariant checks on every\n  context switch, callout lateness histograms, self-test framework,\n  UBSan trap mode, static analysis via clang.\n- QEMU `virt` machine: virtio-mmio devices, PLIC, OpenSBI, Sv39 paging\n  (identity-mapped, 2 MiB superpages with on-demand shattering).\n\n## Quick start\n\nPrimary development target is QEMU on Linux with standard tooling\n(`make`, `python3`, RISC-V cross toolchain, QEMU).\n\nSLIRP networking (local host access):\n\n```bash\nmake defconfig          # generate .config from configs\u002Fdefconfig\nDEBUG=2 make run        # build and launch in QEMU (http:\u002F\u002Flocalhost:8080)\n```\n\nTAP networking (guest at `192.168.100.2`, Linux + iptables required):\n\n```bash\nexport IF=eth0          # outward-facing host interface\n.\u002Fscripts\u002Fsetup_vm_network.sh\nTAP=1 make run\n```\n\nValidation:\n\n```bash\nmake check              # HTTP integration tests (SLIRP)\nmake check-selftest     # semihosting self-tests (CONFIG_SEMIHOSTING=y)\nmake check-smp          # SMP-focused checks (CONFIG_SMP=y)\n```\n\nFor Kconfig usage, defconfigs, fragments, and feature flags, see\n[docs\u002Fbuild.md](docs\u002Fbuild.md).\n\n## HTTP and REST API surface\n\nThe web server (`user\u002Fnet\u002Fweb.c`) provides both static file serving and\ndynamic REST API endpoints. Current API surface:\n\n| Endpoint | Method | Description |\n|----------|--------|-------------|\n| `\u002Fapi\u002Fstats` | GET | Kernel stats (tasks, IRQs, memory, scheduler, callout, security) as JSON |\n| `\u002Fapi\u002Ftcp` | GET | TCP connection table (including cwnd\u002Fssthresh per connection) as JSON |\n| `\u002Fapi\u002Farp` | GET | ARP table as JSON |\n| `\u002Fapi\u002Fklog` | GET | Kernel log ring buffer as JSON |\n| `\u002Fapi\u002Ffs?path=X` | GET | Directory listing as JSON |\n| `\u002Fapi\u002Ffs\u002Fread?path=X` | GET | File content as text\u002Fplain |\n| `\u002Fapi\u002Fshell\u002Fin` | GET\u002FPOST | Web terminal: create session \u002F submit command |\n| `\u002Fapi\u002Fshell\u002Fout` | GET | Web terminal: read output (polling) |\n| `\u002Fapi\u002Fsse\u002Ftest` | GET | SSE test endpoint (chunked transfer encoding) |\n\nWebSocket upgrade is supported for real-time communication (e.g.,\nterminal streaming). Additional MIME types and API endpoints can be\nadded in `user\u002Fnet\u002Fweb.c`.\n\n## Documentation\n\n- [docs\u002Fdesign.md](docs\u002Fdesign.md): design philosophy, Linux\u002FPlan 9\n  lineage, SMP as a structural property, real-time and networking\n  co-design, programming style.\n- [docs\u002Finternals.md](docs\u002Finternals.md): boot, tasks, networking, TCP\n  state machine and allocators, RAM fs.\n- [docs\u002Fbuild.md](docs\u002Fbuild.md): Kconfig system, defconfigs,\n  fragments, feature flags, build\u002Fruntime knobs, validation\n  shortcuts.\n- [docs\u002Fsecurity.md](docs\u002Fsecurity.md): threat model, deployment\n  constraints, syscall authorization, memory safety hardenings.\n- [docs\u002Fdebugging.md](docs\u002Fdebugging.md): GDB workflow, lockdep,\n  scheduler invariants, callout telemetry, UBSan trap mode, self-test\n  framework, semihosting console.\n- [docs\u002Fpse51-matrix.md](docs\u002Fpse51-matrix.md): per-syscall PSE51\n  conformance status.\n\n## License\n\n`mazu` is available under a permissive\n[MIT](https:\u002F\u002Fopensource.org\u002Flicense\u002Fmit)-style license. Use of this\nsource code is governed by a MIT license that can be found in the\n[LICENSE](LICENSE) file.\n","MazuNIX\u002Fmazu 是一个结合了Linux严谨性和Plan 9简洁性的实时操作系统（RTOS），专为多处理器系统设计，支持实时调度和集成网络。其核心功能包括SMP正确性、硬实时调度以及内核集成的TCP\u002FIP网络堆栈，确保所有任务在统一的地址空间和锁机制下运行。技术特点上，mazu采用了类似Linux的子系统模块化设计和同步原语，并且借鉴了Plan 9“一切皆文件”的理念来简化系统监控与管理。该操作系统特别适用于需要高可靠性、低延迟通信及精确控制的嵌入式应用场景，如工业自动化、物联网设备等。","2026-06-11 03:53:03","CREATED_QUERY"]