On 2010-04-18 at 01:06:41 [+0200], Axel Dörfler <axeld@xxxxxxxxxxxxxxxx> wrote: > ingo_weinhold@xxxxxx wrote: > > +int > > +pthread_spin_lock(pthread_spinlock_t* lock) > > +{ > > + while (atomic_test_and_set((int32*)&lock->lock, LOCKED, > > UNLOCKED) == > LOCKED) > > + ; // spin > > + return 0; > > +} > > Shouldn't it at least call thread_yield() here? I guess on UP machines that would definitely make sense. On SMP machines I'm not sure. I had a quick look at the NetBSD implementation and they simply spin, calling a pthread__smt_pause() macro which for x86[-64] translates to "rep; nop". CU, Ingo