mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-10-14 02:27:39 -04:00
Remove struct spinlock to cleanup some mess and simplify. It's only used in boosting for multiprocesors and a pure two-corelock heirarchy will do just fine.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@19910 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
e2a169bce5
commit
3cf148945e
4 changed files with 18 additions and 99 deletions
|
@ -961,57 +961,6 @@ void mutex_unlock(struct mutex *m)
|
|||
}
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Simpl-er mutex functions ;)
|
||||
****************************************************************************/
|
||||
#if NUM_CORES > 1
|
||||
void spinlock_init(struct spinlock *l)
|
||||
{
|
||||
corelock_init(&l->cl);
|
||||
l->thread = NULL;
|
||||
l->count = 0;
|
||||
}
|
||||
|
||||
void spinlock_lock(struct spinlock *l)
|
||||
{
|
||||
const unsigned int core = CURRENT_CORE;
|
||||
struct thread_entry *current = cores[core].running;
|
||||
|
||||
if(l->thread == current)
|
||||
{
|
||||
/* current core already owns it */
|
||||
l->count++;
|
||||
return;
|
||||
}
|
||||
|
||||
/* lock against other processor cores */
|
||||
corelock_lock(&l->cl);
|
||||
|
||||
/* take ownership */
|
||||
l->thread = current;
|
||||
}
|
||||
|
||||
void spinlock_unlock(struct spinlock *l)
|
||||
{
|
||||
/* unlocker not being the owner is an unlocking violation */
|
||||
KERNEL_ASSERT(l->thread == cores[CURRENT_CORE].running,
|
||||
"spinlock_unlock->wrong thread\n");
|
||||
|
||||
if(l->count > 0)
|
||||
{
|
||||
/* this core still owns lock */
|
||||
l->count--;
|
||||
return;
|
||||
}
|
||||
|
||||
/* clear owner */
|
||||
l->thread = NULL;
|
||||
|
||||
/* release lock */
|
||||
corelock_unlock(&l->cl);
|
||||
}
|
||||
#endif /* NUM_CORES > 1 */
|
||||
|
||||
/****************************************************************************
|
||||
* Simple semaphore functions ;)
|
||||
****************************************************************************/
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue