reduce the number of per_core calls
This commit is contained in:
parent
28a535dbeb
commit
b228c2260f
1 changed files with 5 additions and 3 deletions
|
@ -81,11 +81,13 @@ inline static int spinlock_destroy(spinlock_t* s) {
|
|||
*/
|
||||
inline static int spinlock_lock(spinlock_t* s) {
|
||||
int32_t ticket;
|
||||
task_t* curr_task;
|
||||
|
||||
if (BUILTIN_EXPECT(!s, 0))
|
||||
return -EINVAL;
|
||||
|
||||
if (s->owner == per_core(current_task)->id) {
|
||||
curr_task = per_core(current_task);
|
||||
if (s->owner == curr_task->id) {
|
||||
s->counter++;
|
||||
return 0;
|
||||
}
|
||||
|
@ -94,7 +96,7 @@ inline static int spinlock_lock(spinlock_t* s) {
|
|||
while(atomic_int32_read(&s->dequeue) != ticket) {
|
||||
NOP1;
|
||||
}
|
||||
s->owner = per_core(current_task)->id;
|
||||
s->owner = curr_task->id;
|
||||
s->counter = 1;
|
||||
|
||||
return 0;
|
||||
|
@ -181,7 +183,7 @@ inline static int spinlock_irqsave_lock(spinlock_irqsave_t* s) {
|
|||
s->coreid = CORE_ID;
|
||||
s->flags = flags;
|
||||
s->counter = 1;
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue