The problem is that QEMU uses functions like g_poll or g_main_context_dispatch from the main event loop implemented in glib[1]. It would be very hard to fork glib and QEMU to use some special event notification system designed for HelenOS. As you may know portability of these libraries is not achieved by some os independent layer which would be up to me to implement (combine bits from one platform with bits from the other). It is achieved by using ugly forks based on macros. The platform is expected to be either POSIX like or Windows like not both. My fears seem to be proved wrong though - I haven't find a sign of using WaitFor*Object for files in QEMU or glib. Such a usage of WaitFor*Object on Windows is indeed possible even-though not recommended. Should I not use the filesystem functionality (and to be honest I would rather not), I think there is only one solution that wouldn't mess up half of the code of QEMU and glib.
The solution is this ugly hack: I will implement pipe in a way that instead of a file descriptor it will return an id of pipe structure. This id will be above MAX_OPEN_FILES and marked with a special flag (id | 0x40000000). I will fork the implementation of the read/write function in posix library to use special functions for reading/writing from/into a pipe when it's recognized by using the same flag. Select will then be implemented only for these special file descriptors. [1] https://developer.gnome.org/glib/2.28/glib-The-Main-Event-Loop.html#g-main-context-query 2015-03-16 16:47 GMT+01:00 Jakub Jermar <[email protected]>: > Hi Jan, > > On 16.3.2015 15:37, Jan Mareš wrote: > > I'm working on porting QEMU to HelenOS. QEMU uses an event loop which > > polls for fired events and calls corresponding callbacks if there are > > any. In POSIX systems this is achieved using pipe and select functions, > > on Windows CreateEvent and WaitForObject is used. Sadly, it seems that > > waiting for events is mixed with waiting for actual files which works > > fine on both platforms, but prevents designing a separate event > > mechanism for HelenOS (it would mean creating and altering lot of code > > of QEMU). So I decided that implementing pipe and select for HelenOS > > could be the solution. > > How is CreateEvent and WaitForObject mixed with waiting for a file? > These are generic Windows mechanisms. Using the filesytem functionality, > which is moreover not there yet in HelenOS to mimic > CreateEvent/WaitForObject seems like a bad idea to me. > > Jakub > > _______________________________________________ > HelenOS-devel mailing list > [email protected] > http://lists.modry.cz/listinfo/helenos-devel >
_______________________________________________ HelenOS-devel mailing list [email protected] http://lists.modry.cz/listinfo/helenos-devel
