mirror of
https://github.com/asterinas/asterinas.git
synced 2025-06-20 13:06:33 +00:00
Allow specifying orderings when loading/storing AtomicCpuSet
s
This commit is contained in:
@ -1,6 +1,6 @@
|
||||
// SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
use core::{cmp, mem};
|
||||
use core::{cmp, mem, sync::atomic::Ordering};
|
||||
|
||||
use ostd::cpu::{num_cpus, CpuId, CpuSet};
|
||||
|
||||
@ -14,9 +14,9 @@ pub fn sys_sched_getaffinity(
|
||||
ctx: &Context,
|
||||
) -> Result<SyscallReturn> {
|
||||
let cpu_set = match tid {
|
||||
0 => ctx.thread.atomic_cpu_affinity().load(),
|
||||
0 => ctx.thread.atomic_cpu_affinity().load(Ordering::Relaxed),
|
||||
_ => match thread_table::get_thread(tid) {
|
||||
Some(thread) => thread.atomic_cpu_affinity().load(),
|
||||
Some(thread) => thread.atomic_cpu_affinity().load(Ordering::Relaxed),
|
||||
None => return Err(Error::with_message(Errno::ESRCH, "thread does not exist")),
|
||||
},
|
||||
};
|
||||
@ -39,10 +39,15 @@ pub fn sys_sched_setaffinity(
|
||||
let user_cpu_set = read_cpu_set_from(ctx.user_space(), cpuset_size, cpu_set_ptr)?;
|
||||
|
||||
match tid {
|
||||
0 => ctx.thread.atomic_cpu_affinity().store(&user_cpu_set),
|
||||
0 => ctx
|
||||
.thread
|
||||
.atomic_cpu_affinity()
|
||||
.store(&user_cpu_set, Ordering::Relaxed),
|
||||
_ => match thread_table::get_thread(tid) {
|
||||
Some(thread) => {
|
||||
thread.atomic_cpu_affinity().store(&user_cpu_set);
|
||||
thread
|
||||
.atomic_cpu_affinity()
|
||||
.store(&user_cpu_set, Ordering::Relaxed);
|
||||
}
|
||||
None => return Err(Error::with_message(Errno::ESRCH, "thread does not exist")),
|
||||
},
|
||||
|
Reference in New Issue
Block a user