Extended the "last acquirer" debug stuff to also contain the thread that

released it last, and the counts involved.
Furthermore, release_sem_etc() will now only negate the acquirer thread
ID instead of setting it to -1.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21781 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler
2007-08-01 16:46:24 +00:00
parent edb15b5565
commit 463be7ab63
+16 -4
View File
@@ -50,6 +50,9 @@ struct sem_entry {
team_id owner; // if set to -1, means owned by a port team_id owner; // if set to -1, means owned by a port
#ifdef DEBUG_LAST_ACQUIRER #ifdef DEBUG_LAST_ACQUIRER
thread_id last_acquirer; thread_id last_acquirer;
int32 last_acquire_count;
thread_id last_releaser;
int32 last_release_count;
#endif #endif
} used; } used;
@@ -161,7 +164,10 @@ dump_sem(struct sem_entry *sem)
} else } else
kprintf(" -\n"); kprintf(" -\n");
#ifdef DEBUG_LAST_ACQUIRER #ifdef DEBUG_LAST_ACQUIRER
kprintf("last acquired by: 0x%lx\n", sem->u.used.last_acquirer); kprintf("last acquired by: %ld, count: %ld\n", sem->u.used.last_acquirer,
sem->u.used.last_acquire_count);
kprintf("last released by: %ld, count: %ld\n", sem->u.used.last_releaser,
sem->u.used.last_release_count);
#endif #endif
} else { } else {
kprintf("next: %p\n", sem->u.unused.next); kprintf("next: %p\n", sem->u.unused.next);
@@ -649,8 +655,10 @@ switch_sem_etc(sem_id semToBeReleased, sem_id id, int32 count,
} }
#ifdef DEBUG_LAST_ACQUIRER #ifdef DEBUG_LAST_ACQUIRER
if (thread->sem.acquire_status >= B_OK) if (thread->sem.acquire_status >= B_OK) {
sSems[slot].u.used.last_acquirer = thread_get_current_thread_id(); sSems[slot].u.used.last_acquirer = thread_get_current_thread_id();
sSems[slot].u.used.last_acquire_count = count;
}
#endif #endif
restore_interrupts(state); restore_interrupts(state);
@@ -662,6 +670,7 @@ switch_sem_etc(sem_id semToBeReleased, sem_id id, int32 count,
} else { } else {
#ifdef DEBUG_LAST_ACQUIRER #ifdef DEBUG_LAST_ACQUIRER
sSems[slot].u.used.last_acquirer = thread_get_current_thread_id(); sSems[slot].u.used.last_acquirer = thread_get_current_thread_id();
sSems[slot].u.used.last_acquire_count = count;
#endif #endif
} }
@@ -715,13 +724,16 @@ release_sem_etc(sem_id id, int32 count, uint32 flags)
// doesn't have any use outside the kernel // doesn't have any use outside the kernel
if ((flags & B_CHECK_PERMISSION) != 0 if ((flags & B_CHECK_PERMISSION) != 0
&& sSems[slot].u.used.owner == team_get_kernel_team_id()) { && sSems[slot].u.used.owner == team_get_kernel_team_id()) {
dprintf("thread %ld tried to release kernel semaphore.\n", thread_get_current_thread()->id); dprintf("thread %ld tried to release kernel semaphore.\n",
thread_get_current_thread_id());
status = B_NOT_ALLOWED; status = B_NOT_ALLOWED;
goto err; goto err;
} }
#ifdef DEBUG_LAST_ACQUIRER #ifdef DEBUG_LAST_ACQUIRER
sSems[slot].u.used.last_acquirer = -1; sSems[slot].u.used.last_acquirer = -sSems[slot].u.used.last_acquirer;
sSems[slot].u.used.last_releaser = thread_get_current_thread_id();
sSems[slot].u.used.last_release_count = count;
#endif #endif
// clear out a queue we will use to hold all of the threads that we will have to // clear out a queue we will use to hold all of the threads that we will have to