Claudio Ciccani schrieb: > Denis Oliver Kropp wrote: >> Still looking for a way to interrupt a blocking read() >> from outside (other thread) without using a signal. >> >> Simply closing it wasn't helpful. >> >> I also couldn't find anything if we'd be using select() or poll(). >> >> pthread_cancel() interrupts the read, but it also interrupts >> too many other places... and is the one to be removed anyways. >> >> Any idea apart from using a pipe with select() on the pipe and device? >> > > This is why pthread_cancel() exists.
But pthread_cancel() also terminates the thread at mutex_lock for example which would be bad if a lock is already taken. I'd prefer having well chosen voluntary exit points. > Apart from that, where exactly are you having that problem with the > read() call (i.e. which driver,module,...)? I started testing with the linux_input driver. The thread blocks in a read(fd). I tried to replace the pthread_cancel() by closing the file descriptor, but that didn't bother the prending read(). > I ask beceuse I have removed pthread_cancel() calls in my code and > I am not experiencing problems with read() calls. > The only remaining thing to do is to replace the pthread_cond_wait() > call in the vt switcher thread with a loop of > pthread_cond_timedwait()/direct_thread_testcancel(). The VT thread is different. It doesn't block on a file descriptor. I thought about using select() or poll() with a timeout and periodically check whether to exit the thread or not, but that's not a clean solution. For each thread handled that way you loose 0-timeout time. Having all threads wake up several times per second is also not acceptable. -- Best regards, Denis Oliver Kropp .------------------------------------------. | DirectFB - Hardware accelerated graphics | | http://www.directfb.org/ | "------------------------------------------" _______________________________________________ directfb-dev mailing list [email protected] http://mail.directfb.org/cgi-bin/mailman/listinfo/directfb-dev
