I'm not too keen on coroutines either, I'd prefer to use normal
multithreading, but was thinking of solutions to use when multithreading
is limited. Even with multithreading I find things look complicated.
I was doing some thinking last week of the different ways to structure an
OS. Currently mine is monolithic but with drivers and filesystems as threads
within the kernel, these normally communicate with Amiga-style message
passing, ports and signals (which are a sleep/wakeup mechanism).
Technically drivers and filesystems don't need to be threads, they can just
be called on the context of the caller, it's upto the driver whether to use
a thread or not. The last time I touched the code it more or less worked
but I would've liked to allow threads to read from a cache while another
thread was blocked on IO to a driver. Sounds simple but it appears
difficult in this case due to the driver structure and different synch
primitives like message passing and condition variables being hard to work
together. Perhaps having the cache managed by it's own task and confining
everything to message passing would've made it work or I could've
completely redesigned the drivers and filesystems not to use threads..
I imagine early Unix's sleep/wakeup mechanisms and no-preemption in the
kernel was a bit like using coroutines and simpler than using threaded
drivers and other sync primitives.
As I said I was thinking of other ways to structure an OS, not that I'm
going to start developing my OS again, just wanted to thiink about things.
Originally I was thinking about OSes structured as protection rings and
subjects unrelated to filesystems. Then turned my attention to message
passing microkernels and how they could support some form of
multithreading/concurrency on a single thread.
>> It appears that QNX used coroutines in the FSys server, not sure
>> if they still do or if they've moved to real threads
>>
>> Oh and AmigaDOS used coroutines as well it would seem:
>
> Unfortunately, neither of those say why coroutines were used, or how.
> They could've just been merging two existing code pieces to work
> together, instead of writing the driver from scratch. Or, not ...
Could be.the case, but from reading other QNX posts from that time
period I gather that QNX didn't have multithreading so they used coroutines
in FSys to allow requests to block on IO but still be able to service other
requests.
--
Marv