Re: newbie questions about while (1) in kernel mode and spinlocks

Paolo Ornati
2006-12-21T10:21:48Z

> spin_lock(&lck);
> down(&sem); /* I know that one shouldn't sleep when holding a lock */
> /* but I want to understand why */

I suppose because the lock is held for an indefinite amount of time and
any other process that try to get that lock will "spin" and burn CPU
without doing anything useful (locking the process in kernel mode and
preventing the execution of other processes on that CPU if there
isn't any type of PREEMPTION).

:)

spin_lock is a "while(1) {...}" thing...