Release mutex in char driver after a certain period of time has elapsed

71 views Asked by At

I have a char driver and a userspace program which reads and writes from it. A certain command from the userspace program makes the char driver to acquire a lock and another to release the lock. This happens in the Write function of the driver. How can I include a timeout mechanism in the driver to release the mutex just in case I accidently quit the userspace program while the driver was holding the mutex.

1

There are 1 answers

0
AudioBubble On

Looks like your current design is wrong.

It is an invariant that you don't leave the kernel with locks held. In fact if you had debug enabled (which for the most part you can take from any debug kernel for any distro) the kernel itself would tell you there is something wrong.