7 ms·
Octox: Unix-like OS in Rust inspired by xv6-riscv
- deleted 3y ago[deleted]
- xolve 3y agoOP, would be nice if you add a license to the repo.
- o8vm 3y agoThanks! Is this notation in the README not enough: https://github.com/o8vm/octox#license https://github.com/o8vm/octox#license ?
- Arnavion 3y agoBoth those licenses require you to add the license text as a file to the codebase. Eg see the "How to apply the Apache License to your work" section in the Apache license link that you have there. Since it's dual-licensed you can add one as LICENSE-MIT and the other as LICENSE-APACHE.
- o8vm 3y agoOh, I see! Thank you very much. I'll add both later!
- tbillington 3y agoIf you like you can copy what I did: https://github.com/tbillington/bevy_toon_shader https://github.com/tbillington/bevy_toon_shader, which I copied from https://github.com/bevyengine/bevy/ https://github.com/bevyengine/bevy/ (just that my repo has was less stuff, so might be easier to copy from).
- Santosh83 3y agoWhy does it seem like 80 to 90% of hobby OS projects that are started are "Unix-like?" Don't we already have a huge variety of Unix-like OSes out there? Why not explore new models?
- lmm 3y agoUnix is a lot more amenable than most older OSes to being implemented by a disparate group of people with limited communication, hence why GNU was originally set up as a reimplementation of unix.
- pjmlp 3y agoBecause it is less effort to copy already existing stacks, than be creative in trailing not yet discovered paths.
- packetlost 3y agoWe need more Plan 9-likes! But more seriously, the Unix/POSIX-like OS is a pretty good model, but IMO we could do better, especially in the microkernel front.
- mysterydip 3y agoWhat does "written in safe Rust as much as possible" mean? Are there functions with no equivalent in rust?
- OtomotO 3y agoInterfacing with hardware means you have to drop to "unsafe" rust at some (few) points. "Unsafe" rust isn't named good, because it's still safer than e.g. C. Some invariants you cannot break in rust, no matter if "safe" or "unsafe"
- xeonmc 3y agoWould it be more aptly named “risky rust”?
- kzrdude 3y agoYes! Another apt name would be "trustme". (The normal case in Rust is trust the compiler - and all the people who wrote "trustme" code that you depend on!)
- tialaramex 3y ago> it's still safer than e.g. C. This is arguable and I think overall it's actually harder to correctly write unsafe Rust, even if sometimes maybe in some sense safer than C when you screw up. In Rust everything has to obey Rust's semantic constraints. For safe Rust that's fine because the language itself promises you're obeying. You can't introduce anything which would be a problem, so you needn't even care what those problems are. But in unsafe Rust you are responsible for the same guarantees that safe Rust gave everybody. And the rules you're responsible for obeying are truly difficult so that you may not properly understand them. If you screw up, that's instantly Undefined Behaviour. Let's take a fairly old but brutal real example from Rust's standard library. core::mem::uninitialized<T>(). This function is labelled deprecated (as well as unsafe) in your Rust, but once upon a time it was the usual way to make some uninitialized buffer in which to construct something. But it was actually UB almost always†. Because what it says is, OK, I know I didn't initialize a T, but trust me, I'll sort that out later, lets say this is a T anyway. And for a time people persuaded themselves that this is OK for at least some types. After all, if T was u8 (a byte) then who cares what its value is, any value is valid, isn't it? Well, yes, but "uninitialized" isn't a value, it's a 257th possible state, the compiler knows we didn't initialize this, and therefore all optimisations are valid even if they wouldn't be valid for any possible initialized state of the memory - we didn't initialize it so we're not entitled to assume it had any of those values. In C you will get away with this but in Rust you've created Undefined Behaviour, which is not OK. Today you would use the MaybeUninit<T> type so that you can explicitly initialize it (once you have something to initialize it with) and then MaybeUninit::assume_init() to get your T instead now that it's initialized, and (if you did it correctly) that is safe. † If T is a Zero Size Type then this function isn't dangerous, because it makes nothing and then says this nothing is actually a T, and the compiler says well, thanks for telling me, I don't really care but whatever. No UB. Likely this only happens in generic code, but it's safe.
- cnuts 3y agoThat's really cool, great job!
- prydt 3y agoAwesome! What are some good resources on making a simple UNIX like operating system? I know osdev wiki exists, anything else?
- o8vm 3y agoThanks!For me https://pdos.csail.mit.edu/6.S081/2020/xv6/book-riscv-rev1.pdf https://pdos.csail.mit.edu/6.S081/2020/xv6/book-riscv-rev1.p... was quite helpful! but Someday I will write a book on how to implement this OS step by step in Japanese.
- bakul 3y agoHow does this compare with https://github.com/dancrossnyc/rxv64 https://github.com/dancrossnyc/rxv64 ? From its README.md: rxv64 is a pedagogical operating system written in Rust that targets multiprocessor x86_64 machines. It is a reimplementation of the xv6 operating system from MIT.
- o8vm 3y agooctox is also different in that the kernel, userland, mkfs, and build system are all implemented in Rust, and I think it is also different at the type level, for example, octox using mpmc for Pipe, and using OnceLock and LazyLock for static variable initialization.
- bakul 3y agoThanks. rxv64 kernel (the much harder part), syslib and ulib are in rust. Replacing userland C with rust would not be hard. Ideally a general purpose OS should support programs written in any of the common programming languages so it would make sense to have some programs in another language to keep the OS API "honest"!
- o8vm 3y agooctox aims to provide a user library similar to Rust’s std, but implementing it is somewhat difficult.
- snvzz 3y agoI immediately notice that o8vm targets RISC-V, whereas rxv64 targets a legacy ISA.
- yjftsjthsd-h 3y agoIs it really a "legacy" ISA if it's actively developed by two different companies (and will be for a long time to come) and is utterly dominant in servers, desktops, and laptops today?
- freecodyx 3y agoNot related to the project. Most of the code is unsafe. I really find rust counterintuitive. This is just a note to myself. * rust uses llvm as a backend * rust tries to solve the memory issues commonly found in C bu enforcing a programming paradigm which allow the compiler to detect them at compile time. * it tries to provide 0 cost abstractions It works but the code is ugly
- segfaltnh 3y agoWait, most of _what_ code is unsafe? Aside from this one comment it sounds like you just came here to shit on Rust, lol.
- stevefan1999 3y agoOh you have did what I did in the shadow...I wonder if I later GPL'd it the license won't be compatible to take the code in...But I runs in x86_64 with custom QEMU UEFI loader anyway
- yasuoyamasaki 3y agoJust one hacker developed this OS, ya know!