kernel/source/scheduler/synchro.cpp
// check if the lock is held by the current thread in a race-free manner.
check if the lock is held by the current thread in a race-free manner.
check if the lock is held by the current thread in a race - free manner .
static bool check_selflock(scheduler::Thread* holder)
	{
		if(!holder)
			return false;
		scheduler::pause();
		auto cur = scheduler::getCurrentThread();
		auto ret = (cur == holder);
		scheduler::unpause();
		return ret;
	}
static bool check_selflock ( scheduler :: Thread * holder ) { if ( ! holder ) return false ; scheduler :: pause ( ) ; auto cur = scheduler :: getCurrentThread ( ) ; auto ret = ( cur == holder ) ; scheduler :: unpause ( ) ; return ret ; }
check if the lock is held by the current thread in a race-free manner.
check if the lock is held by the current thread in a race - free manner .
// prevent the situation where we get the current thread and store it in a register, // and then we get scheduled, leading to a stale comparison. (since obviously before // the lock is acquired, the scheduler is not paused).