From 4498339f501b9899116cb6ef4ba9a6ac95aa97bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=9D=E5=80=89=E6=B0=B4=E5=B8=8C?= Date: Wed, 26 Nov 2025 20:22:20 +0800 Subject: [PATCH 1/3] refactor: axtask --- Cargo.lock | 67 ++++------------------ api/src/file/event.rs | 74 ++++++++++++------------- api/src/file/fs.rs | 14 ++--- api/src/file/pipe.rs | 95 ++++++++++++++++---------------- api/src/file/signalfd.rs | 84 ++++++++++++++-------------- api/src/syscall/io_mpx/epoll.rs | 17 +++--- api/src/syscall/io_mpx/poll.rs | 15 ++--- api/src/syscall/io_mpx/select.rs | 15 ++--- api/src/syscall/task/clone.rs | 4 +- api/src/terminal/ldisc.rs | 8 +-- api/src/vfs/dev/fb.rs | 2 +- api/src/vfs/dev/log.rs | 2 +- api/src/vfs/dev/tty.rs | 24 +++++--- api/src/vfs/dev/tty/ntty.rs | 2 +- arceos | 2 +- core/src/config/aarch64.rs | 2 +- core/src/config/loongarch64.rs | 2 +- core/src/config/riscv64.rs | 2 +- core/src/config/x86_64.rs | 2 +- src/entry.rs | 6 +- 20 files changed, 200 insertions(+), 239 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 9003f75b..d5801805 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -453,7 +453,6 @@ dependencies = [ "axplat-loongarch64-qemu-virt", "axplat-riscv64-qemu-virt", "axplat-x86-pc", - "axpoll", "cfg-if", "heapless 0.8.0", "kernel_guard", @@ -743,16 +742,15 @@ dependencies = [ "cfg-if", "cpumask", "crate_interface", + "event-listener", "extern-trait", - "futures", + "futures-util", "kernel_guard", "kspin", "lazyinit", "log", "memory_addr", "percpu", - "pin-project", - "spin 0.10.0", "weak-map", ] @@ -1234,30 +1232,6 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "77ce24cb58228fbb8aa041425bb1050850ac19177686ea6e0f41a70416f56fdb" -[[package]] -name = "futures" -version = "0.3.31" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "65bc07b1a8bc7c85c5f2e110c476c7389b4554ba72af57d8445ea63a576b0876" -dependencies = [ - "futures-channel", - "futures-core", - "futures-io", - "futures-sink", - "futures-task", - "futures-util", -] - -[[package]] -name = "futures-channel" -version = "0.3.31" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2dff15bf788c671c1934e366d07e30c1814a8ef514e1af724a602e8a2fbe1b10" -dependencies = [ - "futures-core", - "futures-sink", -] - [[package]] name = "futures-core" version = "0.3.31" @@ -1265,16 +1239,15 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "05f29059c0c2090612e8d742178b0580d2dc940c837851ad723096f87af6663e" [[package]] -name = "futures-io" -version = "0.3.31" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e5c1b78ca4aae1ac06c48a526a655760685149f0d465d21f37abfe57ce075c6" - -[[package]] -name = "futures-sink" +name = "futures-macro" version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e575fab7d1e0dcb8d0c7bcf9a63ee213816ab51902e6d244a95819acacf1d4f7" +checksum = "162ee34ebcb7c64a8abebc059ce0fee27c2262618d7b60ed8faf72fef13c3650" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.111", +] [[package]] name = "futures-task" @@ -1289,7 +1262,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9fa08315bb612088cc391249efdc3bc77536f16c91f6cf495e6fbe85b20a4a81" dependencies = [ "futures-core", - "futures-sink", + "futures-macro", "futures-task", "pin-project-lite", "pin-utils", @@ -1802,26 +1775,6 @@ dependencies = [ "syn 2.0.111", ] -[[package]] -name = "pin-project" -version = "1.1.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "677f1add503faace112b9f1373e43e9e054bfdd22ff1a63c1bc485eaec6a6a8a" -dependencies = [ - "pin-project-internal", -] - -[[package]] -name = "pin-project-internal" -version = "1.1.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6e918e4ff8c4549eb882f14b3a4bc8c8bc93de829416eacf579f1207a8fbf861" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.111", -] - [[package]] name = "pin-project-lite" version = "0.2.16" diff --git a/api/src/file/event.rs b/api/src/file/event.rs index 84b89fa9..058e5132 100644 --- a/api/src/file/event.rs +++ b/api/src/file/event.rs @@ -8,7 +8,7 @@ use core::{ use axerrno::AxError; use axio::{Buf, BufMut, Read, Write}; use axpoll::{IoEvents, PollSet, Pollable}; -use axtask::future::Poller; +use axtask::future::{block_on, poll_io}; use crate::file::{FileLike, Kstat, SealedBuf, SealedBufMut}; @@ -40,28 +40,26 @@ impl FileLike for EventFd { return Err(AxError::InvalidInput); } - Poller::new(self, IoEvents::IN) - .non_blocking(self.nonblocking()) - .poll(|| { - let result = - self.count - .fetch_update(Ordering::Release, Ordering::Acquire, |count| { - if count > 0 { - let dec = if self.semaphore { 1 } else { count }; - Some(count - dec) - } else { - None - } - }); - match result { - Ok(count) => { - dst.write(&count.to_ne_bytes())?; - self.poll_tx.wake(); - Ok(size_of::()) + block_on(poll_io(self, IoEvents::IN, self.nonblocking(), || { + let result = self + .count + .fetch_update(Ordering::Release, Ordering::Acquire, |count| { + if count > 0 { + let dec = if self.semaphore { 1 } else { count }; + Some(count - dec) + } else { + None } - Err(_) => Err(AxError::WouldBlock), + }); + match result { + Ok(count) => { + dst.write(&count.to_ne_bytes())?; + self.poll_tx.wake(); + Ok(size_of::()) } - }) + Err(_) => Err(AxError::WouldBlock), + } + })) } fn write(&self, src: &mut SealedBuf) -> axio::Result { @@ -76,26 +74,24 @@ impl FileLike for EventFd { return Err(AxError::InvalidInput); } - Poller::new(self, IoEvents::OUT) - .non_blocking(self.nonblocking()) - .poll(|| { - let result = - self.count - .fetch_update(Ordering::Release, Ordering::Acquire, |count| { - if u64::MAX - count > value { - Some(count + value) - } else { - None - } - }); - match result { - Ok(_) => { - self.poll_rx.wake(); - Ok(size_of::()) + block_on(poll_io(self, IoEvents::OUT, self.nonblocking(), || { + let result = self + .count + .fetch_update(Ordering::Release, Ordering::Acquire, |count| { + if u64::MAX - count > value { + Some(count + value) + } else { + None } - Err(_) => Err(AxError::WouldBlock), + }); + match result { + Ok(_) => { + self.poll_rx.wake(); + Ok(size_of::()) } - }) + Err(_) => Err(AxError::WouldBlock), + } + })) } fn stat(&self) -> axio::Result { diff --git a/api/src/file/fs.rs b/api/src/file/fs.rs index 8c92b8de..567678a1 100644 --- a/api/src/file/fs.rs +++ b/api/src/file/fs.rs @@ -12,7 +12,7 @@ use axfs_ng::{FS_CONTEXT, FsContext}; use axfs_ng_vfs::{Location, Metadata, NodeFlags}; use axpoll::{IoEvents, Pollable}; use axsync::Mutex; -use axtask::future::Poller; +use axtask::future::{block_on, poll_io}; use linux_raw_sys::general::{AT_EMPTY_PATH, AT_FDCWD, AT_SYMLINK_NOFOLLOW}; use super::{FileLike, Kstat, get_file_like}; @@ -131,9 +131,9 @@ impl FileLike for File { if likely(self.is_blocking()) { inner.read(dst) } else { - Poller::new(self, IoEvents::IN) - .non_blocking(self.nonblocking()) - .poll(|| inner.read(dst)) + block_on(poll_io(self, IoEvents::IN, self.nonblocking(), || { + inner.read(dst) + })) } } @@ -142,9 +142,9 @@ impl FileLike for File { if likely(self.is_blocking()) { inner.write(src) } else { - Poller::new(self, IoEvents::OUT) - .non_blocking(self.nonblocking()) - .poll(|| inner.write(src)) + block_on(poll_io(self, IoEvents::OUT, self.nonblocking(), || { + inner.write(src) + })) } } diff --git a/api/src/file/pipe.rs b/api/src/file/pipe.rs index 423c3921..1428c914 100644 --- a/api/src/file/pipe.rs +++ b/api/src/file/pipe.rs @@ -10,7 +10,10 @@ use axerrno::{AxError, AxResult}; use axio::{Buf, BufMut, Read, Write}; use axpoll::{IoEvents, PollSet, Pollable}; use axsync::Mutex; -use axtask::{current, future::Poller}; +use axtask::{ + current, + future::{block_on, poll_io}, +}; use linux_raw_sys::{general::S_IFIFO, ioctl::FIONREAD}; use memory_addr::PAGE_SIZE_4K; use ringbuf::{ @@ -117,28 +120,26 @@ impl FileLike for Pipe { return Ok(0); } - Poller::new(self, IoEvents::IN) - .non_blocking(self.nonblocking()) - .poll(|| { - let read = { - let cons = self.shared.buffer.lock(); - let (left, right) = cons.as_slices(); - let mut count = dst.write(left)?; - if count >= left.len() { - count += dst.write(right)?; - } - unsafe { cons.advance_read_index(count) }; - count - }; - if read > 0 { - self.shared.poll_tx.wake(); - Ok(read) - } else if self.closed() { - Ok(0) - } else { - Err(AxError::WouldBlock) + block_on(poll_io(self, IoEvents::IN, self.nonblocking(), || { + let read = { + let cons = self.shared.buffer.lock(); + let (left, right) = cons.as_slices(); + let mut count = dst.write(left)?; + if count >= left.len() { + count += dst.write(right)?; } - }) + unsafe { cons.advance_read_index(count) }; + count + }; + if read > 0 { + self.shared.poll_tx.wake(); + Ok(read) + } else if self.closed() { + Ok(0) + } else { + Err(AxError::WouldBlock) + } + })) } fn write(&self, src: &mut SealedBuf) -> AxResult { @@ -151,34 +152,32 @@ impl FileLike for Pipe { } let mut total_written = 0; - let non_blocking = self.nonblocking(); - Poller::new(self, IoEvents::OUT) - .non_blocking(non_blocking) - .poll(|| { - if self.closed() { - raise_pipe(); - return Err(AxError::BrokenPipe); - } - let written = { - let mut prod = self.shared.buffer.lock(); - let (left, right) = prod.vacant_slices_mut(); - let mut count = src.read(unsafe { left.assume_init_mut() })?; - if count >= left.len() { - count += src.read(unsafe { right.assume_init_mut() })?; - } - unsafe { prod.advance_write_index(count) }; - count - }; - if written > 0 { - self.shared.poll_rx.wake(); - total_written += written; - if total_written == size || non_blocking { - return Ok(total_written); - } + block_on(poll_io(self, IoEvents::OUT, self.nonblocking(), || { + if self.closed() { + raise_pipe(); + return Err(AxError::BrokenPipe); + } + + let written = { + let mut prod = self.shared.buffer.lock(); + let (left, right) = prod.vacant_slices_mut(); + let mut count = src.read(unsafe { left.assume_init_mut() })?; + if count >= left.len() { + count += src.read(unsafe { right.assume_init_mut() })?; } - Err(AxError::WouldBlock) - }) + unsafe { prod.advance_write_index(count) }; + count + }; + if written > 0 { + self.shared.poll_rx.wake(); + total_written += written; + if total_written == size || self.nonblocking() { + return Ok(total_written); + } + } + Err(AxError::WouldBlock) + })) } fn stat(&self) -> AxResult { diff --git a/api/src/file/signalfd.rs b/api/src/file/signalfd.rs index ea9ed587..1d6b599f 100644 --- a/api/src/file/signalfd.rs +++ b/api/src/file/signalfd.rs @@ -9,15 +9,19 @@ use core::{ use axerrno::{AxError, AxResult}; use axio::{BufMut, Write}; use axpoll::{IoEvents, PollSet, Pollable}; -use axtask::{current, future::Poller}; +use axtask::{ + current, + future::{block_on, poll_io}, +}; +use spin::RwLock; use starry_core::task::AsThread; use starry_signal::{SignalInfo, SignalSet}; -use spin::RwLock; use zerocopy::{Immutable, IntoBytes}; use crate::file::{FileLike, Kstat, SealedBufMut}; -/// The size of signalfd_siginfo structure (128 bytes as per Linux specification) +/// The size of signalfd_siginfo structure (128 bytes as per Linux +/// specification) const SIGNALFD_SIGINFO_SIZE: usize = 128; /// signalfd_siginfo structure layout @@ -25,24 +29,24 @@ const SIGNALFD_SIGINFO_SIZE: usize = 128; #[repr(C)] #[derive(Immutable, IntoBytes)] struct SignalfdSiginfo { - ssi_signo: u32, // Signal number - ssi_errno: i32, // Error number (unused) - ssi_code: i32, // Signal code - ssi_pid: u32, // PID of sender - ssi_uid: u32, // Real UID of sender - ssi_fd: i32, // File descriptor (SIGIO) - ssi_tid: u32, // Kernel timer ID (POSIX timers) - ssi_band: u32, // Band event (SIGIO) - ssi_overrun: u32, // POSIX timer overrun count - ssi_trapno: u32, // Trap number that caused signal - ssi_status: i32, // Exit status or signal (SIGCHLD) - ssi_int: i32, // Integer sent by sigqueue(2) - ssi_ptr: u64, // Pointer sent by sigqueue(2) - ssi_utime: u64, // User CPU time consumed (SIGCHLD) - ssi_stime: u64, // System CPU time consumed (SIGCHLD) - ssi_addr: u64, // Address that generated signal - ssi_addr_lsb: u16, // Least significant bit of address - _pad: [u8; 46], // Padding to make it 128 bytes + ssi_signo: u32, // Signal number + ssi_errno: i32, // Error number (unused) + ssi_code: i32, // Signal code + ssi_pid: u32, // PID of sender + ssi_uid: u32, // Real UID of sender + ssi_fd: i32, // File descriptor (SIGIO) + ssi_tid: u32, // Kernel timer ID (POSIX timers) + ssi_band: u32, // Band event (SIGIO) + ssi_overrun: u32, // POSIX timer overrun count + ssi_trapno: u32, // Trap number that caused signal + ssi_status: i32, // Exit status or signal (SIGCHLD) + ssi_int: i32, // Integer sent by sigqueue(2) + ssi_ptr: u64, // Pointer sent by sigqueue(2) + ssi_utime: u64, // User CPU time consumed (SIGCHLD) + ssi_stime: u64, // System CPU time consumed (SIGCHLD) + ssi_addr: u64, // Address that generated signal + ssi_addr_lsb: u16, // Least significant bit of address + _pad: [u8; 46], // Padding to make it 128 bytes } const _: [(); SIGNALFD_SIGINFO_SIZE] = [(); mem::size_of::()]; @@ -123,27 +127,25 @@ impl FileLike for Signalfd { return Err(AxError::InvalidInput); } - Poller::new(self, IoEvents::IN) - .non_blocking(self.nonblocking()) - .poll(|| { - if let Some(sig_info) = self.dequeue_signal() { - // Convert SignalInfo to SignalfdSiginfo - let sfd_info = SignalfdSiginfo::from_signal_info(&sig_info); - - // Write the structure to the destination buffer - let bytes = sfd_info.as_bytes(); - dst.write(bytes)?; - - // Wake up other waiters if there are more signals pending - if self.has_pending_signals() { - self.poll_rx.wake(); - } - - Ok(SIGNALFD_SIGINFO_SIZE) - } else { - Err(AxError::WouldBlock) + block_on(poll_io(self, IoEvents::IN, self.nonblocking(), || { + if let Some(sig_info) = self.dequeue_signal() { + // Convert SignalInfo to SignalfdSiginfo + let sfd_info = SignalfdSiginfo::from_signal_info(&sig_info); + + // Write the structure to the destination buffer + let bytes = sfd_info.as_bytes(); + dst.write(bytes)?; + + // Wake up other waiters if there are more signals pending + if self.has_pending_signals() { + self.poll_rx.wake(); } - }) + + Ok(SIGNALFD_SIGINFO_SIZE) + } else { + Err(AxError::WouldBlock) + } + })) } fn write(&self, _src: &mut crate::file::SealedBuf) -> AxResult { diff --git a/api/src/syscall/io_mpx/epoll.rs b/api/src/syscall/io_mpx/epoll.rs index e06fec2b..05b76286 100644 --- a/api/src/syscall/io_mpx/epoll.rs +++ b/api/src/syscall/io_mpx/epoll.rs @@ -2,7 +2,7 @@ use core::time::Duration; use axerrno::{AxError, AxResult}; use axpoll::IoEvents; -use axtask::future::Poller; +use axtask::future::{self, block_on, poll_io}; use bitflags::bitflags; use linux_raw_sys::general::{ EPOLL_CLOEXEC, EPOLL_CTL_ADD, EPOLL_CTL_DEL, EPOLL_CTL_MOD, epoll_event, timespec, @@ -95,13 +95,14 @@ fn do_epoll_wait( with_replacen_blocked( nullable!(sigmask.get_as_ref())?.copied(), - || match Poller::new(epoll.as_ref(), IoEvents::IN) - .timeout(timeout) - .poll(|| epoll.poll_events(events)) - { - Ok(n) => Ok(n as isize), - Err(AxError::TimedOut) => Ok(0), - Err(e) => Err(e), + || match block_on(future::timeout( + timeout, + poll_io(epoll.as_ref(), IoEvents::IN, false, || { + epoll.poll_events(events) + }), + )) { + Ok(r) => r.map(|n| n as _), + Err(_) => Ok(0), }, ) } diff --git a/api/src/syscall/io_mpx/poll.rs b/api/src/syscall/io_mpx/poll.rs index bf617804..30fae238 100644 --- a/api/src/syscall/io_mpx/poll.rs +++ b/api/src/syscall/io_mpx/poll.rs @@ -3,7 +3,7 @@ use alloc::vec::Vec; use axerrno::{AxError, AxResult}; use axhal::time::TimeValue; use axpoll::IoEvents; -use axtask::future::Poller; +use axtask::future::{self, block_on, poll_io}; use linux_raw_sys::general::{POLLNVAL, pollfd, timespec}; use starry_signal::SignalSet; @@ -53,9 +53,9 @@ fn do_poll( let fds = FdPollSet(fds); with_replacen_blocked(sigmask, || { - match Poller::new(&fds, IoEvents::empty()) - .timeout(timeout) - .poll(|| { + match block_on(future::timeout( + timeout, + poll_io(&fds, IoEvents::empty(), false, || { let mut res = 0usize; for ((fd, events), revents) in fds.0.iter().zip(revents.iter_mut()) { let mut result = fd.poll(); @@ -77,9 +77,10 @@ fn do_poll( } else { Err(AxError::WouldBlock) } - }) { - Err(AxError::TimedOut) => Ok(0), - other => other, + }), + )) { + Ok(r) => r, + Err(_) => Ok(0), } }) } diff --git a/api/src/syscall/io_mpx/select.rs b/api/src/syscall/io_mpx/select.rs index edac547f..3ff65f99 100644 --- a/api/src/syscall/io_mpx/select.rs +++ b/api/src/syscall/io_mpx/select.rs @@ -3,7 +3,7 @@ use core::{fmt, time::Duration}; use axerrno::{AxError, AxResult}; use axpoll::IoEvents; -use axtask::future::Poller; +use axtask::future::{self, block_on, poll_io}; use bitmaps::Bitmap; use linux_raw_sys::{ general::*, @@ -108,9 +108,9 @@ fn do_select( unsafe { FD_ZERO(exceptfds) }; } with_replacen_blocked(sigmask.copied(), || { - match Poller::new(&fds, IoEvents::empty()) - .timeout(timeout) - .poll(|| { + match block_on(future::timeout( + timeout, + poll_io(&fds, IoEvents::empty(), false, || { let mut res = 0usize; for ((fd, interested), index) in fds.0.iter().zip(fd_indices.iter().copied()) { let events = fd.poll() & *interested; @@ -138,9 +138,10 @@ fn do_select( } Err(AxError::WouldBlock) - }) { - Err(AxError::TimedOut) => Ok(0), - other => other, + }), + )) { + Ok(r) => r, + Err(_) => Ok(0), } }) } diff --git a/api/src/syscall/task/clone.rs b/api/src/syscall/task/clone.rs index e7a05d60..fc643319 100644 --- a/api/src/syscall/task/clone.rs +++ b/api/src/syscall/task/clone.rs @@ -3,7 +3,7 @@ use alloc::sync::Arc; use axerrno::{AxError, AxResult}; use axfs_ng::FS_CONTEXT; use axhal::uspace::UserContext; -use axtask::{TaskExtProxy, current, spawn_task}; +use axtask::{AxTaskExt, current, spawn_task}; use bitflags::bitflags; use kspin::SpinNoIrq; use linux_raw_sys::general::*; @@ -218,7 +218,7 @@ pub fn sys_clone( if flags.contains(CloneFlags::CHILD_CLEARTID) { thr.set_clear_child_tid(child_tid); } - *new_task.task_ext_mut() = Some(unsafe { TaskExtProxy::from_impl(thr) }); + *new_task.task_ext_mut() = Some(unsafe { AxTaskExt::from_impl(thr) }); let task = spawn_task(new_task); add_task_to_table(&task); diff --git a/api/src/terminal/ldisc.rs b/api/src/terminal/ldisc.rs index 01415265..06cf6be5 100644 --- a/api/src/terminal/ldisc.rs +++ b/api/src/terminal/ldisc.rs @@ -8,7 +8,7 @@ use core::{ use axerrno::{AxError, AxResult}; use axpoll::{IoEvents, PollSet, Pollable}; -use axtask::future::{Poller, block_on}; +use axtask::future::{block_on, poll_io}; use linux_raw_sys::general::{ ECHOCTL, ECHOK, ICRNL, IGNCR, ISIG, VEOF, VERASE, VKILL, VMIN, VTIME, }; @@ -255,7 +255,7 @@ impl LineDiscipline { ProcessMode::Manual => Processor::Manual(reader), ProcessMode::External(register) => { let poll_rx = Arc::new(PollSet::new()); - axtask::spawn( + axtask::spawn_with_name( { let poll_rx = poll_rx.clone(); let poll_tx = poll_tx.clone(); @@ -360,12 +360,12 @@ impl LineDiscipline { _ => unreachable!(), }; let pollable = WaitPollable(set); - Poller::new(&pollable, IoEvents::IN).poll(|| { + block_on(poll_io(&pollable, IoEvents::IN, false, || { total_read += self.buf_rx.pop_slice(&mut buf[total_read..]); self.poll_tx.wake(); (total_read >= vmin) .then_some(total_read) .ok_or(AxError::WouldBlock) - }) + })) } } diff --git a/api/src/vfs/dev/fb.rs b/api/src/vfs/dev/fb.rs index d5506f63..02191a41 100644 --- a/api/src/vfs/dev/fb.rs +++ b/api/src/vfs/dev/fb.rs @@ -93,7 +93,7 @@ pub struct FrameBuffer { } impl FrameBuffer { pub fn new() -> Self { - axtask::spawn( + axtask::spawn_with_name( || axtask::future::block_on(refresh_task()), "fb-refresh".into(), ); diff --git a/api/src/vfs/dev/log.rs b/api/src/vfs/dev/log.rs index 00e279f1..edc306b5 100644 --- a/api/src/vfs/dev/log.rs +++ b/api/src/vfs/dev/log.rs @@ -9,7 +9,7 @@ use axnet::{ pub fn bind_dev_log() -> LinuxResult<()> { let server = UnixSocket::new(DgramTransport::new(1)); server.bind(SocketAddrEx::Unix(UnixSocketAddr::Path("/dev/log".into())))?; - axtask::spawn( + axtask::spawn_with_name( move || { let mut buf = [0u8; 65536]; loop { diff --git a/api/src/vfs/dev/tty.rs b/api/src/vfs/dev/tty.rs index 47510238..a26dfc32 100644 --- a/api/src/vfs/dev/tty.rs +++ b/api/src/vfs/dev/tty.rs @@ -5,7 +5,10 @@ use axerrno::{AxError, AxResult}; use axfs_ng_vfs::NodeFlags; use axpoll::{IoEvents, Pollable}; use axsync::Mutex; -use axtask::{current, future::Poller}; +use axtask::{ + current, + future::{block_on, poll_io}, +}; use starry_core::{task::AsThread, vfs::SimpleFs}; use starry_process::Process; use starry_vm::{VmMutPtr, VmPtr}; @@ -81,13 +84,18 @@ impl Tty { impl DeviceOps for Tty { fn read_at(&self, buf: &mut [u8], _offset: u64) -> AxResult { - Poller::new(&self.terminal.job_control, IoEvents::IN).poll(|| { - if self.is_ptm || self.terminal.job_control.current_in_foreground() { - self.ldisc.lock().read(buf) - } else { - Err(AxError::WouldBlock) - } - }) + block_on(poll_io( + &self.terminal.job_control, + IoEvents::IN, + false, + || { + if self.is_ptm || self.terminal.job_control.current_in_foreground() { + self.ldisc.lock().read(buf) + } else { + Err(AxError::WouldBlock) + } + }, + )) } fn write_at(&self, buf: &[u8], _offset: u64) -> AxResult { diff --git a/api/src/vfs/dev/tty/ntty.rs b/api/src/vfs/dev/tty/ntty.rs index 88f149f1..a4a1d55b 100644 --- a/api/src/vfs/dev/tty/ntty.rs +++ b/api/src/vfs/dev/tty/ntty.rs @@ -1,6 +1,6 @@ use alloc::{boxed::Box, sync::Arc}; -use axhal::irq::register_irq_waker; +use axtask::future::register_irq_waker; use lazy_static::lazy_static; use super::Tty; diff --git a/arceos b/arceos index 4d1be138..13bf0019 160000 --- a/arceos +++ b/arceos @@ -1 +1 @@ -Subproject commit 4d1be13842ab800e585c375f723694224b4a1a7e +Subproject commit 13bf00191b2f9b2d7b3f33d39bda9797104207b9 diff --git a/core/src/config/aarch64.rs b/core/src/config/aarch64.rs index ad2bf5a3..15288e85 100644 --- a/core/src/config/aarch64.rs +++ b/core/src/config/aarch64.rs @@ -1,5 +1,5 @@ /// The size of the kernel stack. -pub const KERNEL_STACK_SIZE: usize = 0x40000; +pub const KERNEL_STACK_SIZE: usize = 0x4_0000; /// The base address of the user space. pub const USER_SPACE_BASE: usize = 0x1000; diff --git a/core/src/config/loongarch64.rs b/core/src/config/loongarch64.rs index af26534d..9383e419 100644 --- a/core/src/config/loongarch64.rs +++ b/core/src/config/loongarch64.rs @@ -1,5 +1,5 @@ /// The size of the kernel stack. -pub const KERNEL_STACK_SIZE: usize = 0x40000; +pub const KERNEL_STACK_SIZE: usize = 0x4_0000; /// The base address of the user space. pub const USER_SPACE_BASE: usize = 0x1000; diff --git a/core/src/config/riscv64.rs b/core/src/config/riscv64.rs index af26534d..9383e419 100644 --- a/core/src/config/riscv64.rs +++ b/core/src/config/riscv64.rs @@ -1,5 +1,5 @@ /// The size of the kernel stack. -pub const KERNEL_STACK_SIZE: usize = 0x40000; +pub const KERNEL_STACK_SIZE: usize = 0x4_0000; /// The base address of the user space. pub const USER_SPACE_BASE: usize = 0x1000; diff --git a/core/src/config/x86_64.rs b/core/src/config/x86_64.rs index ad2bf5a3..15288e85 100644 --- a/core/src/config/x86_64.rs +++ b/core/src/config/x86_64.rs @@ -1,5 +1,5 @@ /// The size of the kernel stack. -pub const KERNEL_STACK_SIZE: usize = 0x40000; +pub const KERNEL_STACK_SIZE: usize = 0x4_0000; /// The base address of the user space. pub const USER_SPACE_BASE: usize = 0x1000; diff --git a/src/entry.rs b/src/entry.rs index 3212a9e6..2d902291 100644 --- a/src/entry.rs +++ b/src/entry.rs @@ -6,7 +6,7 @@ use alloc::{ use axfs_ng::FS_CONTEXT; use axhal::uspace::UserContext; use axsync::Mutex; -use axtask::{TaskExtProxy, spawn_task}; +use axtask::{AxTaskExt, spawn_task}; use starry_api::{file::FD_TABLE, task::new_user_task, vfs::dev::tty::N_TTY}; use starry_core::{ mm::{copy_from_kernel, load_user_app, new_user_aspace_empty}, @@ -60,11 +60,11 @@ pub fn run_initproc(args: &[String], envs: &[String]) -> i32 { } let thr = Thread::new(pid, proc_data); - *task.task_ext_mut() = Some(unsafe { TaskExtProxy::from_impl(thr) }); + *task.task_ext_mut() = Some(unsafe { AxTaskExt::from_impl(thr) }); let task = spawn_task(task); add_task_to_table(&task); // TODO: wait for all processes to finish - task.join() + task.join().unwrap() } From 06111c5ba1323238b0fa22457d41b0507266d876 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=9D=E5=80=89=E6=B0=B4=E5=B8=8C?= Date: Wed, 26 Nov 2025 20:49:55 +0800 Subject: [PATCH 2/3] update arceos --- arceos | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arceos b/arceos index 13bf0019..f7130c49 160000 --- a/arceos +++ b/arceos @@ -1 +1 @@ -Subproject commit 13bf00191b2f9b2d7b3f33d39bda9797104207b9 +Subproject commit f7130c49534ba1e3d57ccba6f1db1ac8a3198fd3 From 63a16360914758a24ec223c8f1f184636837d820 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=9D=E5=80=89=E6=B0=B4=E5=B8=8C?= Date: Thu, 27 Nov 2025 17:27:43 +0800 Subject: [PATCH 3/3] update arceos --- arceos | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arceos b/arceos index f7130c49..b099d60a 160000 --- a/arceos +++ b/arceos @@ -1 +1 @@ -Subproject commit f7130c49534ba1e3d57ccba6f1db1ac8a3198fd3 +Subproject commit b099d60aff0cb99ce820cd820ac5d871a09902ee