summaryrefslogtreecommitdiff
path: root/firmware/kernel.c
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/kernel.c')
-rw-r--r--firmware/kernel.c51
1 files changed, 0 insertions, 51 deletions
diff --git a/firmware/kernel.c b/firmware/kernel.c
index ae8f354261..0c2b87b139 100644
--- a/firmware/kernel.c
+++ b/firmware/kernel.c
@@ -962,57 +962,6 @@ void mutex_unlock(struct mutex *m)
962} 962}
963 963
964/**************************************************************************** 964/****************************************************************************
965 * Simpl-er mutex functions ;)
966 ****************************************************************************/
967#if NUM_CORES > 1
968void spinlock_init(struct spinlock *l)
969{
970 corelock_init(&l->cl);
971 l->thread = NULL;
972 l->count = 0;
973}
974
975void spinlock_lock(struct spinlock *l)
976{
977 const unsigned int core = CURRENT_CORE;
978 struct thread_entry *current = cores[core].running;
979
980 if(l->thread == current)
981 {
982 /* current core already owns it */
983 l->count++;
984 return;
985 }
986
987 /* lock against other processor cores */
988 corelock_lock(&l->cl);
989
990 /* take ownership */
991 l->thread = current;
992}
993
994void spinlock_unlock(struct spinlock *l)
995{
996 /* unlocker not being the owner is an unlocking violation */
997 KERNEL_ASSERT(l->thread == cores[CURRENT_CORE].running,
998 "spinlock_unlock->wrong thread\n");
999
1000 if(l->count > 0)
1001 {
1002 /* this core still owns lock */
1003 l->count--;
1004 return;
1005 }
1006
1007 /* clear owner */
1008 l->thread = NULL;
1009
1010 /* release lock */
1011 corelock_unlock(&l->cl);
1012}
1013#endif /* NUM_CORES > 1 */
1014
1015/****************************************************************************
1016 * Simple semaphore functions ;) 965 * Simple semaphore functions ;)
1017 ****************************************************************************/ 966 ****************************************************************************/
1018#ifdef HAVE_SEMAPHORE_OBJECTS 967#ifdef HAVE_SEMAPHORE_OBJECTS