Changeset 22510
- Timestamp:
- 10/11/07 13:55:27 (14 months ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
haiku/trunk/src/tests/add-ons/kernel/kernelland_emu.cpp
r19405 r22510 821 821 822 822 823 int 823 int32 824 824 recursive_lock_get_recursion(recursive_lock *lock) 825 825 { … … 864 864 865 865 866 bool 866 status_t 867 867 recursive_lock_lock(recursive_lock *lock) 868 868 { 869 thread_id th id = find_thread(NULL);870 bool retval = false; 871 872 if (thid != lock->holder) {873 acquire_sem(lock->sem);874 875 lock->holder = thid; 876 retval = true;869 thread_id thread = find_thread(NULL); 870 871 if (thread != lock->holder) { 872 status_t status = acquire_sem(lock->sem); 873 if (status < B_OK) 874 return status; 875 876 lock->holder = thread; 877 877 } 878 878 lock->recursion++; 879 return retval;880 } 881 882 883 bool 879 return B_OK; 880 } 881 882 883 void 884 884 recursive_lock_unlock(recursive_lock *lock) 885 885 { 886 thread_id thid = find_thread(NULL); 887 bool retval = false; 888 889 if (thid != lock->holder) 886 if (find_thread(NULL) != lock->holder) 890 887 panic("recursive_lock %p unlocked by non-holder thread!\n", lock); 891 888 892 889 if (--lock->recursion == 0) { 893 890 lock->holder = -1; 894 release_sem(lock->sem); 895 retval = true; 896 } 897 return retval; 891 release_sem_etc(lock->sem, 1, 0/*B_DO_NOT_RESCHEDULE*/); 892 } 898 893 } 899 894 … … 935 930 936 931 937 void 932 status_t 938 933 mutex_lock(mutex *mutex) 939 934 { … … 942 937 // ToDo: if acquire_sem() fails, we shouldn't panic - but we should definitely 943 938 // change the mutex API to actually return the status code 944 if (acquire_sem(mutex->sem) == B_OK) { 945 if (me == mutex->holder) 946 panic("mutex_lock failure: mutex %p (sem = 0x%lx) acquired twice by thread 0x%lx\n", mutex, mutex->sem, me); 947 } 939 status_t status = acquire_sem(mutex->sem); 940 if (status < B_OK) 941 return status; 942 943 if (me == mutex->holder) 944 panic("mutex_lock failure: mutex %p (sem = 0x%lx) acquired twice by thread 0x%lx\n", mutex, mutex->sem, me); 948 945 949 946 mutex->holder = me; 947 return B_OK; 950 948 } 951 949
