diff options
Diffstat (limited to 'firmware/kernel.c')
-rw-r--r-- | firmware/kernel.c | 45 |
1 files changed, 6 insertions, 39 deletions
diff --git a/firmware/kernel.c b/firmware/kernel.c index 803c224640..204f3e8141 100644 --- a/firmware/kernel.c +++ b/firmware/kernel.c | |||
@@ -1127,15 +1127,12 @@ void mutex_unlock(struct mutex *m) | |||
1127 | /**************************************************************************** | 1127 | /**************************************************************************** |
1128 | * Simpl-er mutex functions ;) | 1128 | * Simpl-er mutex functions ;) |
1129 | ****************************************************************************/ | 1129 | ****************************************************************************/ |
1130 | void spinlock_init(struct spinlock *l IF_COP(, unsigned int flags)) | 1130 | #if NUM_CORES > 1 |
1131 | void spinlock_init(struct spinlock *l) | ||
1131 | { | 1132 | { |
1132 | l->locked = 0; | 1133 | corelock_init(&l->cl); |
1133 | l->thread = NULL; | 1134 | l->thread = NULL; |
1134 | l->count = 0; | 1135 | l->count = 0; |
1135 | #if NUM_CORES > 1 | ||
1136 | l->task_switch = flags & SPINLOCK_TASK_SWITCH; | ||
1137 | corelock_init(&l->cl); | ||
1138 | #endif | ||
1139 | } | 1136 | } |
1140 | 1137 | ||
1141 | void spinlock_lock(struct spinlock *l) | 1138 | void spinlock_lock(struct spinlock *l) |
@@ -1148,24 +1145,7 @@ void spinlock_lock(struct spinlock *l) | |||
1148 | return; | 1145 | return; |
1149 | } | 1146 | } |
1150 | 1147 | ||
1151 | #if NUM_CORES > 1 | 1148 | corelock_lock(&l->cl); |
1152 | if (l->task_switch != 0) | ||
1153 | #endif | ||
1154 | { | ||
1155 | /* Let other threads run until the lock is free */ | ||
1156 | while(test_and_set(&l->locked, 1, &l->cl) != 0) | ||
1157 | { | ||
1158 | /* spin and switch until the lock is open... */ | ||
1159 | switch_thread(NULL); | ||
1160 | } | ||
1161 | } | ||
1162 | #if NUM_CORES > 1 | ||
1163 | else | ||
1164 | { | ||
1165 | /* Use the corelock purely */ | ||
1166 | corelock_lock(&l->cl); | ||
1167 | } | ||
1168 | #endif | ||
1169 | 1149 | ||
1170 | l->thread = thread; | 1150 | l->thread = thread; |
1171 | } | 1151 | } |
@@ -1186,23 +1166,10 @@ void spinlock_unlock(struct spinlock *l) | |||
1186 | /* clear owner */ | 1166 | /* clear owner */ |
1187 | l->thread = NULL; | 1167 | l->thread = NULL; |
1188 | 1168 | ||
1189 | #if NUM_CORES > 1 | 1169 | /* release lock */ |
1190 | if (l->task_switch != 0) | ||
1191 | #endif | ||
1192 | { | ||
1193 | /* release lock */ | ||
1194 | #if CONFIG_CORELOCK == SW_CORELOCK | ||
1195 | /* This must be done since our unlock could be missed by the | ||
1196 | test_and_set and leave the object locked permanently */ | ||
1197 | corelock_lock(&l->cl); | ||
1198 | #endif | ||
1199 | l->locked = 0; | ||
1200 | } | ||
1201 | |||
1202 | #if NUM_CORES > 1 | ||
1203 | corelock_unlock(&l->cl); | 1170 | corelock_unlock(&l->cl); |
1204 | #endif | ||
1205 | } | 1171 | } |
1172 | #endif /* NUM_CORES > 1 */ | ||
1206 | 1173 | ||
1207 | /**************************************************************************** | 1174 | /**************************************************************************** |
1208 | * Simple semaphore functions ;) | 1175 | * Simple semaphore functions ;) |