mirror of
https://github.com/asterinas/asterinas.git
synced 2025-06-28 03:43:23 +00:00
Fix the thread status ordering by limiting the API
This commit is contained in:
committed by
Tate, Hongliang Tian
parent
55bf2c847c
commit
1b23182dcc
@ -71,7 +71,7 @@ pub fn tgkill(tid: Tid, tgid: Pid, signal: Option<UserSignal>, ctx: &Context) ->
|
||||
let thread = thread_table::get_thread(tid)
|
||||
.ok_or_else(|| Error::with_message(Errno::ESRCH, "target thread does not exist"))?;
|
||||
|
||||
if thread.status().is_exited() {
|
||||
if thread.is_exited() {
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
|
@ -14,7 +14,7 @@ use crate::{
|
||||
///
|
||||
/// If the thread is not a POSIX thread, this method will panic.
|
||||
pub fn do_exit(thread: &Thread, posix_thread: &PosixThread, term_status: TermStatus) -> Result<()> {
|
||||
if thread.status().is_exited() {
|
||||
if thread.is_exited() {
|
||||
return Ok(());
|
||||
}
|
||||
thread.exit();
|
||||
|
@ -277,7 +277,7 @@ impl PosixThread {
|
||||
let tasks = process.tasks().lock();
|
||||
tasks
|
||||
.iter()
|
||||
.all(|task| Thread::borrow_from_task(task).status().is_exited())
|
||||
.all(|task| Thread::borrow_from_task(task).is_exited())
|
||||
}
|
||||
|
||||
/// Gets the read-only credentials of the thread.
|
||||
|
@ -31,7 +31,6 @@ use crate::{
|
||||
get_current_userspace,
|
||||
prelude::*,
|
||||
process::{do_exit_group, TermStatus},
|
||||
thread::status::ThreadStatus,
|
||||
};
|
||||
|
||||
pub trait SignalContext {
|
||||
@ -107,20 +106,10 @@ pub fn handle_pending_signal(user_ctx: &mut UserContext, ctx: &Context) -> Resul
|
||||
}
|
||||
SigDefaultAction::Ign => {}
|
||||
SigDefaultAction::Stop => {
|
||||
let _ = ctx.thread.atomic_status().compare_exchange(
|
||||
ThreadStatus::Running,
|
||||
ThreadStatus::Stopped,
|
||||
Ordering::AcqRel,
|
||||
Ordering::Relaxed,
|
||||
);
|
||||
let _ = ctx.thread.stop();
|
||||
}
|
||||
SigDefaultAction::Cont => {
|
||||
let _ = ctx.thread.atomic_status().compare_exchange(
|
||||
ThreadStatus::Stopped,
|
||||
ThreadStatus::Running,
|
||||
Ordering::AcqRel,
|
||||
Ordering::Relaxed,
|
||||
);
|
||||
let _ = ctx.thread.resume();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user