From: David Y. <dav...@in...> - 2011-02-21 10:43:01
|
Hi all, I've been almost a week dealing with select. Finally my conclusion is that there is no way to get an equivalent behavior in .NET: ** The problem 'select' takes three sets of file descriptors and blocks until a given time out expires -may be null: block indefinitely, or 0.0s: not blocking-, or an "event" occurs in some of the files in the sets. Such an event can be "ready to read" for the first set, "ready to write" for the second, and "exception on file" for the third (sockets??). The 'pselect' is still funnier. It also involves signals. I implemented 'select' doing a loop, checking for time out and checking the readiness state of the files in the first set. The problem is that there is no way to check readiness in a FileStream in a non-blocking fashion. I thought that 'seek' could be a good approach, but it is blocking, thus not useful for us. Does somebody have a better idea? ** What to do? The benchmark 186.crafty calls to select with 0s timeout (not blocking, not time out) to test stdin. We cannot provide this behavior in .NET (or I didn't find the way). In the case that we decide to provide a version for libstd.so only (and may be a warning o an error in MSCorelibWrapper.dll), I think that the better option would be to provide a wrapper for the system 'select' as core function in __host.c. It doesn't take complex structures as inputs, the 'fdset' type is actually an array. However, my point is to do not implement it at all. Just to modify the Spec2000 benchmark (it already provides platform specific alternatives for the function calling 'select', I think it is fair) |