kern_lock.c (99c9d3490b96615ab51aacd966105d36b2841187) | kern_lock.c (6bdfe06ad9337a33a402bc933006265c30980780) |
---|---|
1/* 2 * Copyright (c) 1995 3 * The Regents of the University of California. All rights reserved. 4 * 5 * Copyright (C) 1997 6 * John S. Dyson. All rights reserved. 7 * 8 * This code contains ideas from software contributed to Berkeley by --- 497 unchanged lines hidden (view full) --- 506 lkp->lk_timo = timo; 507 lkp->lk_lockholder = LK_NOPROC; 508} 509 510/* 511 * Determine the status of a lock. 512 */ 513int | 1/* 2 * Copyright (c) 1995 3 * The Regents of the University of California. All rights reserved. 4 * 5 * Copyright (C) 1997 6 * John S. Dyson. All rights reserved. 7 * 8 * This code contains ideas from software contributed to Berkeley by --- 497 unchanged lines hidden (view full) --- 506 lkp->lk_timo = timo; 507 lkp->lk_lockholder = LK_NOPROC; 508} 509 510/* 511 * Determine the status of a lock. 512 */ 513int |
514lockstatus(lkp) | 514lockstatus(lkp, p) |
515 struct lock *lkp; | 515 struct lock *lkp; |
516 struct proc *p; |
|
516{ 517 int lock_type = 0; 518 519 simple_lock(&lkp->lk_interlock); | 517{ 518 int lock_type = 0; 519 520 simple_lock(&lkp->lk_interlock); |
520 if (lkp->lk_exclusivecount != 0) 521 lock_type = LK_EXCLUSIVE; 522 else if (lkp->lk_sharecount != 0) | 521 if (lkp->lk_exclusivecount != 0) { 522 if (p == NULL || lkp->lk_lockholder == p->p_pid) 523 lock_type = LK_EXCLUSIVE; 524 else 525 lock_type = LK_EXCLOTHER; 526 } else if (lkp->lk_sharecount != 0) |
523 lock_type = LK_SHARED; 524 simple_unlock(&lkp->lk_interlock); 525 return (lock_type); 526} 527 528/* 529 * Determine the number of holders of a lock. 530 */ --- 127 unchanged lines hidden --- | 527 lock_type = LK_SHARED; 528 simple_unlock(&lkp->lk_interlock); 529 return (lock_type); 530} 531 532/* 533 * Determine the number of holders of a lock. 534 */ --- 127 unchanged lines hidden --- |