Skip to main content

 none
WdfWaitLockAcquire called twice RRS feed

  • Question

  • I have a question regarding the use of WdfWaitLockAcquire with timeout.

    If I call WdfWaitLockAcquire and acquire the lock, what happens if I then call WdfWaitLockAcquire with a timeout from the same thread again before releasing it?

    My view is that since I already own the lock it should return success immediately. Is this the case or will it wait for the timeout?

    Thanks!

    Wednesday, September 4, 2019 7:56 AM

Answers

  • Wait locks are NOT recursively acquireable. You would wait the timeout period. If no timeout is provided, you would deadlock the thread

    d -- This posting is provided "AS IS" with no warranties, and confers no rights.

    Wednesday, September 4, 2019 2:11 PM

All replies

  • Wait locks are NOT recursively acquireable. You would wait the timeout period. If no timeout is provided, you would deadlock the thread

    d -- This posting is provided "AS IS" with no warranties, and confers no rights.

    Wednesday, September 4, 2019 2:11 PM
  • Thanks for the reply.

    Can this be used to sleep in kernel mode? Are there any side-effects or risks in using the same lock with timeout for sleeping?

    Thursday, September 5, 2019 7:08 AM
  • You can in theory use this, but why would you.   If you want a sleep equivalent use KeDelayExecutionThread.   If you want to have an ability to cancel the sleep, use a kernel event and KeWaitSingleObject.   The Windows kernel is rich in synchronization mechanisms use the best one for the job.


    Don Burn Windows Driver Consulting Website: http://www.windrvr.com

    Thursday, September 5, 2019 10:36 AM
  • Thank you very much for the reply!
    Friday, September 6, 2019 11:19 AM