Skip to content

[codex] add async tasklet waker#406

Open
xuchang-vivo wants to merge 1 commit into
vivoblueos:mainfrom
xuchang-vivo:xc/add_async_waker
Open

[codex] add async tasklet waker#406
xuchang-vivo wants to merge 1 commit into
vivoblueos:mainfrom
xuchang-vivo:xc/add_async_waker

Conversation

@xuchang-vivo
Copy link
Copy Markdown
Contributor

@xuchang-vivo xuchang-vivo commented Apr 28, 2026

Summary

  • add a per-tasklet RawWaker for the kernel async executor
  • requeue pending tasklets only when their waker fires
  • add a yield_now future and unit coverage

Tasklet State Model

The async executor tracks two things for each tasklet: whether it is currently linked in ASYNC_WORK_QUEUE, and the tasklet scheduling state.

stateDiagram-v2
    [*] --> IDLE: created

    IDLE --> QUEUED: wake and enqueue
    QUEUED --> POLLING: pop from queue and poll

    POLLING --> IDLE: pending and not woken
    POLLING --> WOKEN: woken during poll
    WOKEN --> QUEUED: requeue after pending

    POLLING --> COMPLETED: ready
    COMPLETED --> [*]: no Arc refs remain
Loading

Queue ownership by state:

State In async work queue? Meaning
IDLE No The tasklet is pending but not scheduled. A later waker call can enqueue it.
QUEUED Yes The tasklet is already scheduled. More wake calls are coalesced.
POLLING No The poller popped it from the queue and is currently polling its future.
WOKEN No The tasklet was woken while it was being polled; it will be requeued after Pending.
COMPLETED No The future returned Ready and will not be scheduled again.

pop_front() does not destroy the tasklet. It transfers the list-owned Arc<Tasklet> into the local task variable in poll_inner(). If the future stores cx.waker(), that waker also owns an Arc<Tasklet>, so future events can schedule the same tasklet again.

Validation

  • ninja -C out/qemu_riscv64.release kernel/kernel:check_kernel_by_clippy

@xuchang-vivo xuchang-vivo marked this pull request as ready for review April 30, 2026 04:08
@xuchang-vivo
Copy link
Copy Markdown
Contributor Author

build_prs

@github-actions
Copy link
Copy Markdown

@github-actions
Copy link
Copy Markdown

✅ All jobs completed successfully, see https://github.com/vivoblueos/kernel/actions/runs/25146859694.

Copy link
Copy Markdown
Contributor

@han-jiang277 han-jiang277 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pls add more test cases

@han-jiang277
Copy link
Copy Markdown
Contributor

pls add async design in book.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants