Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

What would you propose instead of forks/signals/process management? There needs to be some way of managing different tasks whether that's threads or otherwise


I suspect the complaint is specifically about the fork and signal APIs as they are in unixen- there's been plenty written about their problems and potential alternatives, e.g. https://www.microsoft.com/en-us/research/uploads/prod/2019/0...

Personally, if I were designing a replacement, I would probably try something like this:

* The lowest level API to create a new process just creates an empty address space with nothing running in it.

* All kernel APIs for manipulating processes take an extra parameter to specify which one.

* Together, these replace "fork, exec" with "create a new address space, map these pages into it, create a thread running in it at this address." (With the right APIs on the side for custom page fault handling and synchronization, you can even reimplement fork+exec yourself on top of this if you want- but you don't have to.)

* Signal handlers would never run on an existing thread- this is too fundamentally fragile. Instead, for cases where you do actually want that sort of asynchronous callback, it runs in its own separate context, where it can act like normal multithreaded code. (Not every use of signals actually needs this, though- a lot of process management signals get routed to threads that explicitly asked for them, and that sort of API probably still makes sense.)

Arguably you don't even need "threads" at the kernel level. You just need to allocate CPU time somehow. I might try to make the API for that look like a callback into userspace (similar to the replacement for signal handlers above) that is then responsible for doing any further scheduling on its own, e.g. among threads in that process.


process_create(executable) would be nice start. the current model of cloning the current process creates a bit of a mess about what the parent and the child should share, and has overhead even in the exec case. now that we have threads, is there any utility in keeping the old fork() model?

not saying anything novel here, but just design a sane and uniform api.

there should be a way for the kernel to do a more controlled upcall into process space. that would scrape out quite a bit of rotten asynch implementation.


How is that different from posix_spawn()?

Also, async implementation is getting a from-scratch rework w/ io_uring anyway.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: