Updated to latest kernel versions.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22510 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler
2007-10-11 17:55:27 +00:00
parent fc6a714ec0
commit e0049e2c37
+21 -23
View File
@@ -820,7 +820,7 @@ user_strlcpy(char *to, const char *from, size_t size)
// #pragma mark - Private locking functions
int
int32
recursive_lock_get_recursion(recursive_lock *lock)
{
thread_id thid = find_thread(NULL);
@@ -863,38 +863,33 @@ recursive_lock_destroy(recursive_lock *lock)
}
bool
status_t
recursive_lock_lock(recursive_lock *lock)
{
thread_id thid = find_thread(NULL);
bool retval = false;
thread_id thread = find_thread(NULL);
if (thid != lock->holder) {
acquire_sem(lock->sem);
lock->holder = thid;
retval = true;
if (thread != lock->holder) {
status_t status = acquire_sem(lock->sem);
if (status < B_OK)
return status;
lock->holder = thread;
}
lock->recursion++;
return retval;
return B_OK;
}
bool
void
recursive_lock_unlock(recursive_lock *lock)
{
thread_id thid = find_thread(NULL);
bool retval = false;
if (thid != lock->holder)
if (find_thread(NULL) != lock->holder)
panic("recursive_lock %p unlocked by non-holder thread!\n", lock);
if (--lock->recursion == 0) {
lock->holder = -1;
release_sem(lock->sem);
retval = true;
release_sem_etc(lock->sem, 1, 0/*B_DO_NOT_RESCHEDULE*/);
}
return retval;
}
@@ -934,19 +929,22 @@ mutex_destroy(mutex *mutex)
}
void
status_t
mutex_lock(mutex *mutex)
{
thread_id me = find_thread(NULL);
// ToDo: if acquire_sem() fails, we shouldn't panic - but we should definitely
// change the mutex API to actually return the status code
if (acquire_sem(mutex->sem) == B_OK) {
if (me == mutex->holder)
panic("mutex_lock failure: mutex %p (sem = 0x%lx) acquired twice by thread 0x%lx\n", mutex, mutex->sem, me);
}
status_t status = acquire_sem(mutex->sem);
if (status < B_OK)
return status;
if (me == mutex->holder)
panic("mutex_lock failure: mutex %p (sem = 0x%lx) acquired twice by thread 0x%lx\n", mutex, mutex->sem, me);
mutex->holder = me;
return B_OK;
}