Changeset 22510

Show
Ignore:
Timestamp:
10/11/07 13:55:27 (14 months ago)
Author:
axeld
Message:

Updated to latest kernel versions.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • haiku/trunk/src/tests/add-ons/kernel/kernelland_emu.cpp

    r19405 r22510  
    821821 
    822822 
    823 int 
     823int32 
    824824recursive_lock_get_recursion(recursive_lock *lock) 
    825825{ 
     
    864864 
    865865 
    866 bool 
     866status_t 
    867867recursive_lock_lock(recursive_lock *lock) 
    868868{ 
    869         thread_id thid = 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; 
    877877        } 
    878878        lock->recursion++; 
    879         return retval; 
    880 } 
    881  
    882  
    883 bool 
     879        return B_OK; 
     880} 
     881 
     882 
     883void 
    884884recursive_lock_unlock(recursive_lock *lock) 
    885885{ 
    886         thread_id thid = find_thread(NULL); 
    887         bool retval = false; 
    888  
    889         if (thid != lock->holder) 
     886        if (find_thread(NULL) != lock->holder) 
    890887                panic("recursive_lock %p unlocked by non-holder thread!\n", lock); 
    891888 
    892889        if (--lock->recursion == 0) { 
    893890                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        } 
    898893} 
    899894 
     
    935930 
    936931 
    937 void 
     932status_t 
    938933mutex_lock(mutex *mutex) 
    939934{ 
     
    942937        // ToDo: if acquire_sem() fails, we shouldn't panic - but we should definitely 
    943938        //      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); 
    948945 
    949946        mutex->holder = me; 
     947        return B_OK; 
    950948} 
    951949