5 ms·
We simply don't have better kernels. POSIX is the epitome of infrastructure. That's it. We did it. It's like asking for something more than Turing completeness
by Bancakes 5y ago
We simply don't have better kernels. POSIX is the epitome of infrastructure. That's it. We did it. It's like asking for something more than Turing completeness - we have everything, just optimise the existing code. To that end, introducing Rust is a pessimization.
- elihu 5y agoThe basic POSIX interface works, but it's hardly optimal. It has a lot of weird built-in assumptions that we're just so used to working around that it's hard to imagine it being any other way. As an example: why can a process only have one current working directory? Wouldn't it be nice to be able to have a process maintain pointers to two or more locations in the filesystem at once? Wouldn't it make software more modular if a library could "chdir" into some directory without worrying about breaking the application that depends on it? The filesystem APIs could be extended with a "CWD" handle argument that can be passed around sort of like a file descriptor instead of having one implicit CWD for the whole process. The same could be done with UIDs. Why not have processes that can use multiple UIDs? Again, you could have UID parameters to API functions that require authorization. POSIX is pretty good by the standards of 80's computers, but in a lot of ways it's showing its age. We can do better. But it's kind of depressing that OS interface design is treated as a solved problem, and so those interfaces stagnate.
- Dylan16807 5y ago> The filesystem APIs could be extended with a "CWD" handle argument that can be passed around Why would you even want a working directory at that point?
- elihu 5y agoWhat's the alternative? To use absolute paths for everything? That seems kind of tedious, and may be slightly less performant if the kernel has to do more dentry lookups. I think the idea of a current working directory is a reasonable one, it's just that the limitation that a process can only have one CWD at a time is kind of arbitrary when you think about it. I could even see having commands that take multiple CWDs. Like a move operation could take a source and a destination CWD as an alternative to specifying source and destination paths.
- Dylan16807 5y agoDirectory file descriptors already exist. I wouldn't call them "current working" directories though. Are you suggesting an expansion of those, or something different from those?
- oalae5niMiel7qu 5y agoIt's a consequence of living in a society where everything is about money. You absolutely could build a better operating system, but doing so wouldn't make you any money, so nobody can afford to do it.
- humanrebar 5y agoIt would be good if APIs like open and creat existed that took something safer than null-terminated strings. Even if kernel devs are careful to avoid the usual pitfalls, it's just a bad API that encourages use of null-terminated strings elsewhere. If you're using other, better string types elsewhere, you often need to make copies to then make system calls (the article hints at that with the addition of a CString type).
- Bancakes 5y agoWhat's wrong with null termination? No, seriously. It's much cleaner than wasting an argument, hence CPU register, for a second pointer. Or heavens forbid, two size_t length and capacity counters.
- humanrebar 5y agoOther than the usual arguments [1], I just said that it causes contamination of other APIs. That's a big problem because string is a "vocabulary type". It is passed around across various libraries within a given process constantly. There should be a lot of convergence on vocabulary types to avoid copying string data around incessantly. Null terminated strings are a poor choice to converge on for high level application code in particular. It's just an inefficient (expensive substrings, redundant length calculation, unclear ownership) and unsafe default for too many use cases. I don't mind certain performance sensitive applications using C strings to avoid extra registers, though even that is a premature optimization in certain situations. [1] See Limitations: https://en.m.wikipedia.org/wiki/Null-terminated_string https://en.m.wikipedia.org/wiki/Null-terminated_string
- orf 5y agoHow do I pass a sub-slice of a source string to a function that expects a null terminated string without copying or modifying the source string?
- Bancakes 5y agoI don't understand the question. Sub-slices are not sub-strings. They are partially constructed objects. But I do get the problem.
- pjmlp 5y agoExcept Cloud as OS doesn't care about POSIX at all, only type 1 hypervisors.