Finally, out goes struct spinlock for anything but mutiprocessor targets where it becomes a reenterable corelock.

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@16105 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Michael Sevakis 2008-01-18 13:12:33 +00:00
parent 3b36b98ff8
commit 6a8379674c
8 changed files with 61 additions and 145 deletions

View file

@ -597,7 +597,7 @@ void mutex_unlock(struct mutex *m)
/* unlocker not being the owner is an unlocking violation */
if(m->thread != thread_get_current())
{
fprintf(stderr, "spinlock_unlock->wrong thread");
fprintf(stderr, "mutex_unlock->wrong thread");
exit(-1);
}
@ -617,52 +617,6 @@ void mutex_unlock(struct mutex *m)
}
}
void spinlock_init(struct spinlock *l)
{
l->locked = 0;
l->thread = NULL;
l->count = 0;
}
void spinlock_lock(struct spinlock *l)
{
struct thread_entry *const thread = thread_get_current();
if (l->thread == thread)
{
l->count++;
return;
}
while(test_and_set(&l->locked, 1))
{
switch_thread(NULL);
}
l->thread = thread;
}
void spinlock_unlock(struct spinlock *l)
{
/* unlocker not being the owner is an unlocking violation */
if(l->thread != thread_get_current())
{
fprintf(stderr, "spinlock_unlock->wrong thread");
exit(-1);
}
if (l->count > 0)
{
/* this thread still owns lock */
l->count--;
return;
}
/* clear owner */
l->thread = NULL;
l->locked = 0;
}
#ifdef HAVE_SEMAPHORE_OBJECTS
void semaphore_init(struct semaphore *s, int max, int start)
{