xv6

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

commit 645f9acbb0c5965e38e9e77d4387ec8bcbb40f70
parent 8a88776ba9dffa2d513f0ba2061b701284aea9c9
Author: Brian Swetland <swetland@frotz.net>
Date:   Thu,  2 Jan 2014 14:03:22 -0800

spinlock: print backtrace when panic'ing on double-acquire

This way you get the backtrace of where the lock was first acquired
in addtion to the backtrace of this call to acquire().

Diffstat:
Mkernel/spinlock.c | 8+++++++-
1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/kernel/spinlock.c b/kernel/spinlock.c @@ -25,8 +25,14 @@ void acquire(struct spinlock *lk) { pushcli(); // disable interrupts to avoid deadlock. - if(holding(lk)) + if(holding(lk)) { + int i; + cprintf("lock '%s':\n", lk->name); + for (i = 0; i < 10; i++) + cprintf(" %p", lk->pcs[i]); + cprintf("\n"); panic("acquire"); + } // The xchg is atomic. // It also serializes, so that reads after acquire are not