int select(int nfds, fd_set *readfds, fd_set *writefds,
fd_set *exceptfds, struct timeval *timeout);
When this function returns (including you cancel it), it sets the value of *timeout as the time still left. Therefore, if we use select() in multithreading environment and *timeout is accessed by more than one thread, uncertainty might appear.
Although it seems simple, sometimes we hardly notice that especially when timeout is hidden in another shared variable of threads.
In my timer utility implementation, I made such an error. Finally I solved it by localizing the struct timeval variable.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment