Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

Wait until deadline variant

Đang mở
#231 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
5/5
Thời gian dự kiến
Hơn một tuần
Mức phù hợp với người mới
30/100
Loại issue
Tính năng
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
wasm
Lĩnh vực
operating-systems

Hướng nghiên cứu

Issue không nêu tên tệp hay bài kiểm thử nào. Hãy bắt đầu bằng cách đọc dependency #230, sau đó xem lại phần thảo luận của đề xuất về Atomics.waitAsync và việc chờ tuyệt đối so với chờ tương đối trên các hệ điều hành và phần cứng nhúng khác nhau. Kết quả cần là một biến thể chờ dựa trên thời hạn được đặc tả với ngữ nghĩa rõ ràng và mối quan hệ của nó với dạng hiện có dựa trên khoảng thời lượng.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

This obviously depends on #230.

Waiting for a duration is useful for simple blocking waits, but event loops generally find deadlines more convenient to work with, since you can just throw all the deadlines into a heap, sort by deadline, and (if your loop is multi-threaded) make your wait condition include timer add/remove events. Browser runtimes would already likely need a similar model anyways because of Atomics.waitAsync, but it's easy for a runtime using one model to expose the other.

Also, the type of wait differs heavily between platforms, with some accepting absolute deadlines, some accepting relative timeouts, and some accepting both:

  • Operating systems:
    • Linux: all futex waits other than FUTEX_WAIT use absolute deadlines, and even that one has an absolute alternative documented in its manpages.
    • Fuschia only uses absolute deadlines in its zx_futex_wait syscall, and offers no relative equivalent.
    • macOS provides both os_sync_wait_on_address_with_deadline and os_sync_wait_on_address_with_timeout.
    • OpenBSD and Windows only offer relative timeouts in their APIs.
    • pthread_condvar_timedwait only uses absolute timeouts.
  • Embedded hardware:
    • 32-bit ARM's SysTick is effectively timeout-based. It decrements every tick until it hits zero, in which it then triggers an interrupt. Setting the register essentially sets the number of ticks to wait before sending the interrupt.
    • RISC-V's privileged spec uses *timecmp registers corresponding to *time targets and triggers an interrupt whenever they're equal, effectively using a deadline-based system.
    • x86-64's HPET works nearly identically to RISC-V's mechanism. (This mostly only has relevance for VM-based server-side runtimes.)
    • The real-time clock specified by ACPI for motherboards uses deadlines. (This is sometimes used on high-end microcontrollers.)

Will note that it's easy to do one in terms of the other.

  • If all waits are absolute, relative waits are as simple as using a deadline of current_time() + timeout.
  • If all waits are relative, absolute waits are as simple as using a timeout of max(target_time - current_time(), 0).
Ngôn ngữ chính
WebAssembly
Star
767
Fork
54
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của WebAssembly/threads

Tất cả issue của WebAssembly/threads

Issue tương tự

Thêm issue về Operating Systems

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.