where can I find the realization code of the function __swtch_pri ?
void
__spin_lock_solid (spin_lock_t *lock)
{
while (__spin_lock_locked (lock) || ! __spin_try_lock (lock))
/* Yield to another thread (system call). */
__swtch_pri (0);
}
Only find declaration in glibc, see below.
/* Attempt to context switch the current thread off the processor. Lower
the thread's priority as much as possible. The thread's priority will
be restored when it runs again. PRIORITY is currently unused. Return
true if there are other threads that can be run and false if not. */
extern boolean_t swtch_pri (int priority);
extern boolean_t __swtch_pri (int priority);
It’s in the Mach kernel. Specifically, see /hurd/gnumach/kern/syscall_subr.c. The GNU C library supports a great many operating system kernels other than just Linux and you’ve probably found this in one of the OS-specific source files.