MohamedG's Log

TW9oYW1lZCBFbC1HZWlzaA==

How to: Use Locks and Prevent Deadlocks?

Multi-threading is used in almost all real-life applications. I summed up my thoughts on use of locks and deadlock prevention in the following related topics: Thread Safety From a thread safety perspective, resources (memory) is classified as either thread-exclusive, read-only, or lock-protected. Unsafe use Accessing static variables or heap-allocated memory after it is published (made… Read more

How to: Debug Deadlocks Using Windbg?

Attach the debugger to the process Load SOS ~* e !clrstack to view the CLR stack of all the threads and where they are Look for System.Threading.Monitor.Enter(System.Object) in the top frames Load SOSEX.dll from http://www.stevestechspot.com/SOSEXUpdatedV11Available.aspx !dlk to detect deadlocks. The output looks like the following: Deadlock detected: CLR thread 5 holds sync block 0018f05c OBJ:010d909c[Microsoft.Sample.SampleEvent]… Read more