The information in this article applies to:
SYMPTOMS
It is possible for a thread in a multithreaded Win32-based application to
block while doing a LockFile() or LockFileEx() API call, even when the
region of the file the thread has requested is not locked by another
thread.
CAUSEThere is a small window of time during which a multithreaded application is vulnerable to this condition. Specifically, if one thread (call it Thread1) is in the process of unlocking a currently locked byte range within a file while a second thread (Thread2) is in the process of obtaining a lock on that same byte range using the same file handle and without specifying the flag LOCKFILE_FAIL_IMMEDIATELY, Thread1 can block, waiting for the region to become available. Ordinarily, when unlocking takes place, blocked threads are released; but in this critical window of time, it is possible for Thread2 to unlock the byte range without Thread1 being released. Thus, Thread1 never resumes operation despite the fact that there is no apparent fault in the logic of the program. RESOLUTION
The deadlock condition described above can only come about if multiple
threads are concurrently doing synchronous I/O using the same file handle.
REFERENCESFor more information about threads, files, and file handles, see the following sections in the "Win32 SDK Programmer's Reference," volume 2, part 3, "System Services":
Additional query words:
Keywords : kbFileIO kbKernBase kbDSupport kbGrpKernBase |
Last Reviewed: December 20, 1999 © 2000 Microsoft Corporation. All rights reserved. Terms of Use. |