News for hackers. Stuff that matters.
Re:Unix-like OS in Rust inspired by xv6-riscv by packetlost on Tuesday July 25, 2023 @03:04PM (#36867695)
We 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.

Re:Unix-like OS in Rust inspired by xv6-riscv by o8vm on Tuesday July 25, 2023 @04:43PM (#36869164)
I would like to implement a plan9-like OS someday!
Re:Unix-like OS in Rust inspired by xv6-riscv by bakul on Tuesday July 25, 2023 @04:45PM (#36869204)
I'd love to see an OS with a Unix API but plan9 like kernel! I will never get around to writing one myself though!
Re:Unix-like OS in Rust inspired by xv6-riscv by jacquesm on Tuesday July 25, 2023 @07:17PM (#36871059)
I got very close to that.
Re:Unix-like OS in Rust inspired by xv6-riscv by bakul on Tuesday July 25, 2023 @07:33PM (#36871193)
Which part? Designing or implementing or something else?
Re:Unix-like OS in Rust inspired by xv6-riscv by jacquesm on Tuesday July 25, 2023 @07:48PM (#36871290)
Implementing. I wrote a QnX clone and it has a lot of parallels with plan9.
Re:Unix-like OS in Rust inspired by xv6-riscv by sillywalk on Thursday July 27, 2023 @12:36AM (#36888969)
Well show it to us :)

For a curious OS nerd that sounds cool. Hacker News Cool.

Re:Unix-like OS in Rust inspired by xv6-riscv by boricj on Tuesday July 25, 2023 @04:46PM (#36869213)
There are a lot of things wrong with plain standard POSIX:

- it's hopelessly out of date and incomplete w.r.t. modern expectations

- fork() is very problematic for multiple reasons, especially in a modern environment (https://www.microsoft.com/en-us/research/uploads/prod/2019/0...)

- process management functions take PIDs and not capabilities, which can cause race conditions

- POSIX hasn't standardized anything better than poll(), yes it works fine in a hobby context but it's not 1987 anymore (and don't get me started on select(): https://github.com/SerenityOS/serenity/pull/11229)

- signals are a mess

- Unix processes have a huge amount of ambient authority, which is problematic when trying to isolate them (chroot(), https://fuchsia.dev/fuchsia-src/concepts/filesystems/dotdot, ...)

- the C POSIX library has a lot of cruft while also missing stuff what programmers actually need (for example, POSIX took nearly 6 years to standardize strlcat()/strlcpy(), the process itself starting 17 years after OpenBSD introduced those functions: https://www.austingroupbugs.net/view.php?id=986)

- ...

Granted, modern production-grade Unix-like operating systems have extensions to deal with most of these issues (posix_spawn, kqueue, pidfd_open...), but they are often non-standard and can be quite janky at times (dnotify, SIGIO...). It also doesn't fix the huge amount of code out there using the legacy facilities like it's still the 1980s.

There are other models out there (Plan 9, Windows, Fuchsia...), but what we really need is to stop putting Unix/POSIX on a pedestal like some holy scripture that shall not be questioned. It's the pinnacle of 1970s operating system designs and it has fossilized so much it's actively turning into oil.

Or at the very least, please stop teaching the next generation that fork() is the greatest thing ever. It's a 50 year old hack kept alive through gratuitous amounts of copy-on-write that should've been scrapped the day Unix was ported to computers with virtual memory and paging.

Re:Unix-like OS in Rust inspired by xv6-riscv by cdcarter on Tuesday July 25, 2023 @05:35PM (#36869915)
> Or at the very least, please stop teaching the next generation that fork() is the greatest thing ever.

Who is saying this? fork() is widely maligned.

Re:Unix-like OS in Rust inspired by xv6-riscv by howinteresting on Tuesday July 25, 2023 @05:41PM (#36869975)
My OS class definitely didn't characterize fork() as maligned, just as a powerful building block. It took me professional experience to realize it sucks.
Re:Unix-like OS in Rust inspired by xv6-riscv by boricj on Tuesday July 25, 2023 @05:42PM (#36869984)
That's not my experience as a French student in the early 2010s. At the very least, I remember that the only process creation model I saw in class was fork()+exec() and there were no disclaimers about it.
Re:Unix-like OS in Rust inspired by xv6-riscv by abnry on Tuesday July 25, 2023 @10:19PM (#36872360)
I found it so strange that to start a child process you had to fork your current process. Not an intuitive idea to me at all.
Re:Unix-like OS in Rust inspired by xv6-riscv by Zambyte on Tuesday July 25, 2023 @10:32PM (#36872450)
I think it makes more sense when you consider that fork was originally the concurrency primitive in Unix. Threads came later. If you want to make some concurrent program, it makes sense to fork without exec. The fact that you can spawn an entirely distinct process with the fork+exec pattern is kind of a coincidence.
Re:Unix-like OS in Rust inspired by xv6-riscv by lloeki on Wednesday July 26, 2023 @05:56AM (#36875188)
I guess spawn-like or invoke-like things are a bit more intuitive at first but they break down when you're out of the trivial case and you have to clean up some but not all resources in a certain way and keep some others to pass on before calling the actual child code.

Then fork starts to make sense as you can do the preparation phase unrestricted by what the spawn API allows and be sure to affect only the child before exec'ing. Probably changing this would require a significantly different resource management model (which is a nice thing to explore)

In some ways, fork+exec sucks, but in others it's also exactly the right tool for some jobs. There's some conceptual simplicity and beauty to it that reminds me of lisp's homoiconicity, where things can be broken down to four fundamental elements (read eval print loop)

Re:Unix-like OS in Rust inspired by xv6-riscv by yjftsjthsd-h on Tuesday July 25, 2023 @05:23PM (#36869809)
This feels contradictory; unix isn't good enough, so nobody implements standard unix, but people need to stop putting unix on a pedestal?
Re:Unix-like OS in Rust inspired by xv6-riscv by pasc1878 on Wednesday July 26, 2023 @07:46AM (#36876106)
Yes - Putting UNIX on a pedestal means that it is basically correct and you just need additions rather than looking at it and saying that UNIX does this badly or even incorrectly and so make incompatabler chnages to improve things.
Re:Unix-like OS in Rust inspired by xv6-riscv by themoonisachees on Wednesday July 26, 2023 @09:27AM (#36877312)
I think part of the issue is that unix does some things correctly (everything is a file comes to mind) and that implementing them without implementing the rest of unix just means you've made a unix-like that's not compatible with normal unix, as opposed to making something new and using the good parts of things you encouter.
Re:Unix-like OS in Rust inspired by xv6-riscv by pasc1878 on Wednesday July 26, 2023 @10:40AM (#36878491)
Why is everything is a file a file correct?

It makes some things easier but it is not the only way - so this does need to be justified.

Re:Unix-like OS in Rust inspired by xv6-riscv by pjmlp on Thursday July 27, 2023 @10:43AM (#36894365)
Everything is a file is certainly not correct, given that is one aspect that Plan 9 has fixed from UNIX's design.
Re:Unix-like OS in Rust inspired by xv6-riscv by packetlost on Tuesday July 25, 2023 @08:31PM (#36871620)
At this point UNIX == Linux for the overwhelming vast majority of users/systems out there. I'm really not a fan of this monoculture, but Linux is quite efficient and there are benefits to everyone using more or less the same platform.

POSIX isn't a great standard at all, but it doesn't really have to be. It's more or less been the "lowest common denominator" for a system for awhile, and it's "ok" at that.

Re:Unix-like OS in Rust inspired by xv6-riscv by pjmlp on Wednesday July 26, 2023 @02:32AM (#36873819)
And then they try to program on macOS....
Re:Unix-like OS in Rust inspired by xv6-riscv by pkphilip on Wednesday July 26, 2023 @01:45AM (#36873557)
Redox OS implemented in Rust aims to be Plan-9-like:

https://www.redox-os.org/faq/#how-redox-is-inspired-by-other...