Skip to content

Commit

Permalink
Replaces TAS with TTAS lock
Browse files Browse the repository at this point in the history
  • Loading branch information
HAKarlsson committed Oct 21, 2024
1 parent 0b875fa commit 02dfe48
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
14 changes: 9 additions & 5 deletions kernel/src/smp/taslock.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,19 @@ void taslock_init(taslock_t *l)

bool taslock_acquire(taslock_t *l)
{
while (!taslock_try_acquire(l))
if (kernel_preempt())
return false;
return true;
while (true) {
while (__atomic_load_n(&l->lock, __ATOMIC_ACQUIRE)) {
if (kernel_preempt())
return false;
}
if (taslock_try_acquire(l))
return true;
}
}

bool taslock_try_acquire(taslock_t *l)
{
return __atomic_fetch_or(&l->lock, 1, __ATOMIC_ACQUIRE);
return !__atomic_fetch_or(&l->lock, 1, __ATOMIC_ACQUIRE);
}

void taslock_release(taslock_t *l)
Expand Down
1 change: 1 addition & 0 deletions kernel/src/syscall.c
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,7 @@ proc_t *handle_sync(proc_t *const p, const sys_args_t *args)
// Full sync invokes scheduler,
// otherwise only update memory.
if (args->sync.full) {
p->timeout = 0;
proc_release(p);
return NULL;
}
Expand Down

0 comments on commit 02dfe48

Please sign in to comment.