Return-Path: william@bourbon.usc.edu Delivery-Date: Wed Oct 29 19:57:44 2008 X-Spam-Checker-Version: SpamAssassin 3.2.3 (2007-08-08) on merlot.usc.edu X-Spam-Level: X-Spam-Status: No, score=-2.4 required=5.0 tests=AWL,BAYES_00 autolearn=ham version=3.2.3 Received: from bourbon.usc.edu (bourbon.usc.edu [128.125.9.75]) by merlot.usc.edu (8.14.1/8.14.1) with ESMTP id m9U2viL2027396 for ; Wed, 29 Oct 2008 19:57:44 -0700 Received: from bourbon.usc.edu (localhost.localdomain [127.0.0.1]) by bourbon.usc.edu (8.14.2/8.14.1) with ESMTP id m9U39B0S027965 for ; Wed, 29 Oct 2008 20:09:11 -0700 Message-Id: <200810300309.m9U39B0S027965@bourbon.usc.edu> To: cs551@merlot.usc.edu Subject: Re: CS551 Final1 - Deadlock Date: Wed, 29 Oct 2008 20:09:11 -0700 From: Bill Cheng Someone wrote: > I got 'Deadlock situation detected/avoided' message when executing the > program. Who's printing out this message? I have never heard of it. > Under gdb, I use 'next' cmd to run step by step and roughly know where/which > thread may cause deadlock. > But it is still hard to catch the bug. Do you know any tips to catch > deadlock? Thank you very much! I don't know a good way. I would go back to the beginning and look at the design and identify all threads and all shared resources. Then look at who is trying to acquire a lock while it is holding another lock. That's the source of deadlock! I'd like to add that it's okay to try to lock a resource while you are holding another lock. But you can pretty much only do this if you have planned to have a locking hierarchy. If you didn't plan for it, then it probably can cause deadlock. -- Bill Cheng // bill.cheng@usc.edu