diff options
| author | Kimplul <kimi.h.kuparinen@gmail.com> | 2022-10-21 21:34:18 +0300 |
|---|---|---|
| committer | Kimplul <kimi.h.kuparinen@gmail.com> | 2022-10-21 21:34:18 +0300 |
| commit | dd7c04a39bd88da8e381bb88078c41b049a6665c (patch) | |
| tree | f5210700cc1789547ae55926c7f9aaa753fbb791 /arch/riscv64/kernel/cpu.c | |
| parent | ec989bbe7d9bb7a844eeddeceaeb7bb7e4d5dab6 (diff) | |
| download | kmi-dd7c04a39bd88da8e381bb88078c41b049a6665c.tar.gz kmi-dd7c04a39bd88da8e381bb88078c41b049a6665c.zip | |
beautification
Diffstat (limited to 'arch/riscv64/kernel/cpu.c')
| -rw-r--r-- | arch/riscv64/kernel/cpu.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/arch/riscv64/kernel/cpu.c b/arch/riscv64/kernel/cpu.c index 4273d02..a730b87 100644 --- a/arch/riscv64/kernel/cpu.c +++ b/arch/riscv64/kernel/cpu.c @@ -7,10 +7,21 @@ */ #include <apos/tcb.h> +#include <apos/atomic.h> + #include <arch/cpu.h> +static atomic_long cpus = 0; + void cpu_assign(struct tcb *t) { + /* bounce cpu id forward, or if first time here, get a cpu id */ + struct tcb *c = cur_tcb(); + if (likely(c)) + t->cpu_id = c->cpu_id; + else + t->cpu_id = cpus++; + __asm__ volatile ("mv tp, %0\n" : : "r" (t) :); } |
