Skip to content

Commit

Permalink
Add testcases for task wait queue
Browse files Browse the repository at this point in the history
  • Loading branch information
hky1999 committed Oct 14, 2024
1 parent 3efb738 commit 07ac4e9
Show file tree
Hide file tree
Showing 11 changed files with 370 additions and 5 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ jobs:
run: make ARCH=${{ matrix.arch }} A=rust/task/irq
- name: Build rust/task/affinity
run: make ARCH=${{ matrix.arch }} A=rust/task/affinity
- name: Build rust/task/wait_queue
run: make ARCH=${{ matrix.arch }} A=rust/task/wait_queue
- name: Build rust/fs/shell
run: make ARCH=${{ matrix.arch }} A=rust/fs/shell
- name: Build rust/net/echoserver
Expand Down
6 changes: 4 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,11 @@ members = [
"rust/task/priority",
"rust/task/tls",
"rust/task/irq",
"rust/task/affinity",
"rust/task/affinity",
"rust/task/wait_queue",
]
exclude = [".arceos"]

[workspace.dependencies]
axstd = { git = "https://github.com/arceos-org/arceos.git" }
# axstd = { git = "https://github.com/arceos-org/arceos.git" }
axstd = { path = "../arceos/ulib/axstd" }
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
A ?= rust/helloworld
AX_ROOT ?= $(PWD)/.arceos
AX_ROOT ?= ../arceos

APP := $(A)
ifeq ($(filter /%,$(A)),)
Expand Down
4 changes: 2 additions & 2 deletions rust/task/parallel/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ fn barrier() {
static BARRIER_COUNT: AtomicUsize = AtomicUsize::new(0);

BARRIER_COUNT.fetch_add(1, Ordering::Relaxed);
api::ax_wait_queue_wait(
api::ax_wait_queue_wait_cond(
&BARRIER_WQ,
|| BARRIER_COUNT.load(Ordering::Relaxed) == NUM_TASKS,
None,
Expand Down Expand Up @@ -60,7 +60,7 @@ fn main() {
#[cfg(feature = "axstd")]
{
// equals to sleep(500ms)
let timeout = api::ax_wait_queue_wait(
let timeout = api::ax_wait_queue_wait_cond(
&AxWaitQueueHandle::new(),
|| false,
Some(std::time::Duration::from_millis(500)),
Expand Down
9 changes: 9 additions & 0 deletions rust/task/wait_queue/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[package]
name = "wait_queue"
version = "0.1.0"
edition = "2021"
authors = ["Keyang Hu <[email protected]>"]
description = "A simple demo to test the wait queue for tasks under ArceOS"

[dependencies]
axstd = { workspace = true, features = ["multitask", "irq"], optional = true }
36 changes: 36 additions & 0 deletions rust/task/wait_queue/expect_info_smp1_fifo.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
smp = 1
build_mode = release
log_level = info

Primary CPU 0 started,
Found physcial memory regions:
.text (READ | EXECUTE | RESERVED)
.rodata (READ | RESERVED)
.data .tdata .tbss .percpu (READ | WRITE | RESERVED)
.percpu (READ | WRITE | RESERVED)
boot stack (READ | WRITE | RESERVED)
.bss (READ | WRITE | RESERVED)
free memory (READ | WRITE | FREE)
Initialize global memory allocator...
Initialize platform devices...
Initialize scheduling...
use FIFO scheduler.
Initialize interrupt handlers...
Primary CPU 0 init OK.
Hello, main task
wait_queue: test_wait()
task TaskId(2) is waiting for tasks to start...
task TaskId(2) is waiting for tasks to finish...
wait_queue: test_wait() OK!
wait_timeout_until: tests begin
wait_timeout_until: test tasks woken up by notification, spawn 16 tasks...
wait_timeout_until: sleep for 100ms to let all tasks start
wait_timeout_until: wake up all tasks who are waiting for timeout through notification
wait_timeout_until: tasks woken up by notification test OK!
wait_timeout_until: test tasks woken up by timeout, spawn 16 tasks...
wait_timeout_until: wait for all tasks to finish
wait_timeout_until: tasks woken up by timeout test OK!
wait_timeout_until: test tasks woken up by notification or timeout, spawn 16 tasks...
wait_timeout_until: test tasks woken up by notification or timeout, test OK!
wait_timeout_until: all tests OK!
Shutting down...
42 changes: 42 additions & 0 deletions rust/task/wait_queue/expect_info_smp4_cfs.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
smp = 4
build_mode = release
log_level = info

CPU 0 started
Found physcial memory regions:
.text (READ | EXECUTE | RESERVED)
.rodata (READ | RESERVED)
.data .tdata .tbss .percpu (READ | WRITE | RESERVED)
.percpu (READ | WRITE | RESERVED)
boot stack (READ | WRITE | RESERVED)
.bss (READ | WRITE | RESERVED)
free memory (READ | WRITE | FREE)
Initialize global memory allocator...
Initialize platform devices...
Initialize scheduling...
use Completely Fair scheduler.
Initialize interrupt handlers...
CPU 0 init OK
CPU 1 started
CPU 2 started
CPU 3 started
CPU 1 init OK
CPU 2 init OK
CPU 3 init OK
Hello, main task
wait_queue: test_wait()
task TaskId(2) is waiting for tasks to start...
task TaskId(2) is waiting for tasks to finish...
wait_queue: test_wait() OK!
wait_timeout_until: tests begin
wait_timeout_until: test tasks woken up by notification, spawn 16 tasks...
wait_timeout_until: sleep for 100ms to let all tasks start
wait_timeout_until: wake up all tasks who are waiting for timeout through notification
wait_timeout_until: tasks woken up by notification test OK!
wait_timeout_until: test tasks woken up by timeout, spawn 16 tasks...
wait_timeout_until: wait for all tasks to finish
wait_timeout_until: tasks woken up by timeout test OK!
wait_timeout_until: test tasks woken up by notification or timeout, spawn 16 tasks...
wait_timeout_until: test tasks woken up by notification or timeout, test OK!
wait_timeout_until: all tests OK!
Shutting down...
42 changes: 42 additions & 0 deletions rust/task/wait_queue/expect_info_smp4_fifo.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
smp = 4
build_mode = release
log_level = info

Primary CPU 0 started,
Found physcial memory regions:
.text (READ | EXECUTE | RESERVED)
.rodata (READ | RESERVED)
.data .tdata .tbss .percpu (READ | WRITE | RESERVED)
.percpu (READ | WRITE | RESERVED)
boot stack (READ | WRITE | RESERVED)
.bss (READ | WRITE | RESERVED)
free memory (READ | WRITE | FREE)
Initialize global memory allocator...
Initialize platform devices...
Initialize scheduling...
use FIFO scheduler.
Initialize interrupt handlers...
CPU 0 init OK
CPU 1 started
CPU 2 started
CPU 3 started
CPU 1 init OK
CPU 2 init OK
CPU 3 init OK
Hello, main task
wait_queue: test_wait()
task TaskId(2) is waiting for tasks to start...
task TaskId(2) is waiting for tasks to finish...
wait_queue: test_wait() OK!
wait_timeout_until: tests begin
wait_timeout_until: test tasks woken up by notification, spawn 16 tasks...
wait_timeout_until: sleep for 100ms to let all tasks start
wait_timeout_until: wake up all tasks who are waiting for timeout through notification
wait_timeout_until: tasks woken up by notification test OK!
wait_timeout_until: test tasks woken up by timeout, spawn 16 tasks...
wait_timeout_until: wait for all tasks to finish
wait_timeout_until: tasks woken up by timeout test OK!
wait_timeout_until: test tasks woken up by notification or timeout, spawn 16 tasks...
wait_timeout_until: test tasks woken up by notification or timeout, test OK!
wait_timeout_until: all tests OK!
Shutting down...
42 changes: 42 additions & 0 deletions rust/task/wait_queue/expect_info_smp4_rr.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
smp = 4
build_mode = release
log_level = info

Primary CPU 0 started,
Found physcial memory regions:
.text (READ | EXECUTE | RESERVED)
.rodata (READ | RESERVED)
.data .tdata .tbss .percpu (READ | WRITE | RESERVED)
.percpu (READ | WRITE | RESERVED)
boot stack (READ | WRITE | RESERVED)
.bss (READ | WRITE | RESERVED)
free memory (READ | WRITE | FREE)
Initialize global memory allocator...
Initialize platform devices...
Initialize scheduling...
use Round-robin scheduler.
Initialize interrupt handlers...
CPU 0 init OK
CPU 1 started
CPU 2 started
CPU 3 started
CPU 1 init OK
CPU 2 init OK
CPU 3 init OK
Hello, main task
wait_queue: test_wait()
task TaskId(2) is waiting for tasks to start...
task TaskId(2) is waiting for tasks to finish...
wait_queue: test_wait() OK!
wait_timeout_until: tests begin
wait_timeout_until: test tasks woken up by notification, spawn 16 tasks...
wait_timeout_until: sleep for 100ms to let all tasks start
wait_timeout_until: wake up all tasks who are waiting for timeout through notification
wait_timeout_until: tasks woken up by notification test OK!
wait_timeout_until: test tasks woken up by timeout, spawn 16 tasks...
wait_timeout_until: wait for all tasks to finish
wait_timeout_until: tasks woken up by timeout test OK!
wait_timeout_until: test tasks woken up by notification or timeout, spawn 16 tasks...
wait_timeout_until: test tasks woken up by notification or timeout, test OK!
wait_timeout_until: all tests OK!
Shutting down...
Loading

0 comments on commit 07ac4e9

Please sign in to comment.