On 17 September 2013 10:36, Martin Decky <[email protected]> wrote: > Off topic: >> I am fairly certain you could elegantly implement all of >> fibril_synch.h (or any other synchronization mechanism) just by using >> futex and sleeper, without directly touching internal details of fibril >> and async framework. >> > > Of course, using sleep and wakeup to implement synchronization primitives > is one of the several possible ways to do it. However, it is hard to to > judge in general whether it is the best way to do it or not. That depends > on the actual implementation. > > If you accept the challenge, feel free to reimplement fibril_synch using > sleep and wakeup. But having custom synchronization means in a single > server is probably not the best thing to do. > > The relative complexity of the current fibril_synch is mostly due to > optimizations, support for timeouts, etc. > > Here's a very quick proof of concept: https://code.launchpad.net/~zarevucky-jiri/helenos/synchro-sleeper
It's undocumented, unproven, untested, and timeouts are unimplemented, but surprisingly enough, it builds and runs. As you can see, I changed the fibril API to include sleep() and wakeup(), supporting sleep timeouts (not yet implemented) and deadlock detection (the same as original). On the other side, fibril_synch.c now contains no inside knowledge of core fibril implementation or async framework, doesn't touch async_futex, and I think it's easier to understand what it does (which is very subjective, I admit). The overall complexity is about the same, I just abstracted away some finer details of waiting on events. However, it should be possible to similarly decouple fibril implementation from async framework, which I think would be a benefit for understandability of both. -- Jirka Z.
_______________________________________________ HelenOS-devel mailing list [email protected] http://lists.modry.cz/listinfo/helenos-devel
