diff options
author | Richard Braun <rbraun@sceen.net> | 2013-05-15 02:12:57 +0200 |
---|---|---|
committer | Richard Braun <rbraun@sceen.net> | 2013-05-15 02:12:57 +0200 |
commit | 05eaaafa89b813e1bd5e34b4d47ec99cdc3a5911 (patch) | |
tree | 84fc50645b2a5ba4f17dfaa2a92059c350956b04 /kern/thread.c | |
parent | b6555e76c36170e60e09125c0bcd7b997f68e4a9 (diff) |
kern/llsync: new module
This module provides lockless synchronization so that reads can safely occur
during updates, without holding a lock. It is based on passive serialization
as described in US patent 4809168, and achieves a goal similar to Linux RCU
(Read-Copy Update).
Diffstat (limited to 'kern/thread.c')
-rw-r--r-- | kern/thread.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/kern/thread.c b/kern/thread.c index fa61976f..a42fd11a 100644 --- a/kern/thread.c +++ b/kern/thread.c @@ -88,6 +88,7 @@ #include <kern/init.h> #include <kern/kmem.h> #include <kern/list.h> +#include <kern/llsync.h> #include <kern/macros.h> #include <kern/mutex.h> #include <kern/panic.h> @@ -473,6 +474,8 @@ thread_runq_schedule(struct thread_runq *runq, struct thread *prev) assert(!cpu_intr_enabled()); spinlock_assert_locked(&runq->lock); + llsync_checkin(thread_runq_id(runq)); + thread_clear_flag(prev, THREAD_RESCHEDULE); thread_runq_put_prev(runq, prev); @@ -1630,6 +1633,7 @@ thread_idle(void *arg) for (;;) { thread_preempt_disable(); + llsync_unregister_cpu(cpu); for (;;) { cpu_intr_disable(); @@ -1642,6 +1646,7 @@ thread_idle(void *arg) cpu_idle(); } + llsync_register_cpu(cpu); thread_preempt_enable(); } } @@ -1847,6 +1852,7 @@ thread_run(void) assert(cpu_intr_enabled()); runq = thread_runq_local(); + llsync_register_cpu(thread_runq_id(runq)); thread = thread_self(); assert(thread == runq->current); assert(thread->preempt == 1); @@ -1894,6 +1900,7 @@ thread_tick(void) assert(!thread_preempt_enabled()); runq = thread_runq_local(); + llsync_commit_checkpoint(thread_runq_id(runq)); thread = thread_self(); spinlock_lock(&runq->lock); |