kernel: Change Thread::team_lock to rw_spinlock
This commit is contained in:
@@ -483,7 +483,7 @@ struct Thread : TeamThreadIteratorEntry<thread_id>, KernelReferenceable,
|
|||||||
|
|
||||||
BKernel::Team *team; // protected by team lock, thread lock, scheduler
|
BKernel::Team *team; // protected by team lock, thread lock, scheduler
|
||||||
// lock, team_lock
|
// lock, team_lock
|
||||||
spinlock team_lock;
|
rw_spinlock team_lock;
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
sem_id sem; // immutable after thread creation
|
sem_id sem; // immutable after thread creation
|
||||||
|
|||||||
@@ -169,7 +169,7 @@ ThreadSignalEvent::Fire()
|
|||||||
|
|
||||||
fSignal->AcquireReference();
|
fSignal->AcquireReference();
|
||||||
// one reference is transferred to send_signal_to_team_locked
|
// one reference is transferred to send_signal_to_team_locked
|
||||||
InterruptsSpinLocker teamLocker(fThread->team_lock);
|
InterruptsReadSpinLocker teamLocker(fThread->team_lock);
|
||||||
SpinLocker locker(fThread->team->signal_lock);
|
SpinLocker locker(fThread->team->signal_lock);
|
||||||
status_t error = send_signal_to_thread_locked(fThread, fSignal->Number(),
|
status_t error = send_signal_to_thread_locked(fThread, fSignal->Number(),
|
||||||
fSignal, B_DO_NOT_RESCHEDULE);
|
fSignal, B_DO_NOT_RESCHEDULE);
|
||||||
|
|||||||
@@ -1494,7 +1494,7 @@ send_signal_to_thread(Thread* thread, const Signal& signal, uint32 flags)
|
|||||||
if (error != B_OK)
|
if (error != B_OK)
|
||||||
return error;
|
return error;
|
||||||
|
|
||||||
InterruptsSpinLocker teamLocker(thread->team_lock);
|
InterruptsReadSpinLocker teamLocker(thread->team_lock);
|
||||||
SpinLocker locker(thread->team->signal_lock);
|
SpinLocker locker(thread->team->signal_lock);
|
||||||
|
|
||||||
error = send_signal_to_thread_locked(thread, signal.Number(), signalToQueue,
|
error = send_signal_to_thread_locked(thread, signal.Number(), signalToQueue,
|
||||||
|
|||||||
@@ -206,7 +206,7 @@ Thread::Thread(const char* name, thread_id threadID, struct cpu_ent* cpu)
|
|||||||
mutex_init_etc(&fLock, lockName, MUTEX_FLAG_CLONE_NAME);
|
mutex_init_etc(&fLock, lockName, MUTEX_FLAG_CLONE_NAME);
|
||||||
|
|
||||||
B_INITIALIZE_SPINLOCK(&time_lock);
|
B_INITIALIZE_SPINLOCK(&time_lock);
|
||||||
B_INITIALIZE_SPINLOCK(&team_lock);
|
B_INITIALIZE_RW_SPINLOCK(&team_lock);
|
||||||
|
|
||||||
// init name
|
// init name
|
||||||
if (name != NULL)
|
if (name != NULL)
|
||||||
@@ -1984,7 +1984,7 @@ thread_exit(void)
|
|||||||
// swap address spaces, to make sure we're running on the kernel's pgdir
|
// swap address spaces, to make sure we're running on the kernel's pgdir
|
||||||
vm_swap_address_space(team->address_space, VMAddressSpace::Kernel());
|
vm_swap_address_space(team->address_space, VMAddressSpace::Kernel());
|
||||||
|
|
||||||
SpinLocker teamLocker(thread->team_lock);
|
WriteSpinLocker teamLocker(thread->team_lock);
|
||||||
SpinLocker schedulerLocker(gSchedulerLock);
|
SpinLocker schedulerLocker(gSchedulerLock);
|
||||||
// removing the thread and putting its death entry to the parent
|
// removing the thread and putting its death entry to the parent
|
||||||
// team needs to be an atomic operation
|
// team needs to be an atomic operation
|
||||||
@@ -3281,7 +3281,7 @@ _user_cancel_thread(thread_id threadID, void (*cancelFunction)(int))
|
|||||||
thread->cancel_function = cancelFunction;
|
thread->cancel_function = cancelFunction;
|
||||||
|
|
||||||
// send the cancellation signal to the thread
|
// send the cancellation signal to the thread
|
||||||
InterruptsSpinLocker teamLocker(thread->team_lock);
|
InterruptsReadSpinLocker teamLocker(thread->team_lock);
|
||||||
SpinLocker locker(thread->team->signal_lock);
|
SpinLocker locker(thread->team->signal_lock);
|
||||||
return send_signal_to_thread_locked(thread, SIGNAL_CANCEL_THREAD, NULL, 0);
|
return send_signal_to_thread_locked(thread, SIGNAL_CANCEL_THREAD, NULL, 0);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user