[ECOS] Re: spin locks
Nick Garnett
nickg@redhat.com
Mon Sep 17 06:37:00 GMT 2001
"Andre Asselin" <asselin@us.ibm.com> writes:
> I was thinking about this some more, and realized that the *_schedlock()
> versions of these routines are necessary for thread vs thread locking as
> well as thread vs DPC locking. If you don't disable scheduling when you
> acquire a spinlock, that CPU can be rescheduled to another thread, and if
> the new thread also tries to acquire the same spinlock, it'll result in a
> deadlock. Therefore, the current spinlock implementation is only useful
> for contexts where you can guarantee that scheduling has already been
> disabled, such as from within an interrupt or DSR.
>
This is true. Threads should really use higher level mechanisms such
as mutexes for synchronization. If these prove too expensive then the
*_intsave() spinlock functions should be used.
Compared with spinlocks, the scheduler lock is a very expensive
mechanism. I am not at all happy about mixing things with such
major differences in behaviour in a single primitive.
--
Nick Garnett, eCos Kernel Architect
Red Hat, Cambridge, UK
More information about the Ecos-discuss
mailing list