[Feature Request] Zero-length queues (a.k.a. rendezvous queues)

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

Maintainer thường phản hồi trong vòng 3 ngày

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
12/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ệ
c

Hướng nghiên cứu

The request concerns queue.c, where the cited check rejects a queue length of zero at creation. Read how xQueueReceive and xQueueSend block and wake waiting tasks before changing anything. Done would mean a zero-length queue can be created and a blocking receive pairs with a non-blocking send, with no buffering. The thread has no maintainer decision yet, so agree on the semantics first.

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

Mô tả

enhancement

Is your feature request related to a problem? Please describe.
I want to send data from task A to task B, but only if the receiving task B is already waiting for the data. Using a FreeRTOS queue does not work for this use-case because they have require a length greater than zero, meaning 1 data element would be buffered (which I do not want, for reasons of memory usage and latency).

Describe the solution you'd like
Queues should allow for their maximum number of elements to be zero. A zero-length queue does not buffer any elements, but only transfers data when a send and receive call pair up. This is sometimes referred to as a "rendezvous queue". Rust's crossbeam-channel implementation describes this as follows:

A special case is zero-capacity channel, which cannot hold any messages. Instead, send and receive operations must appear at the same time in order to pair up and pass the message over.

In my problem, the receiving task would loop with a blocking call to xQueueReceive(queue, buffer, portMAX_DELAY); when it is done processing the previous data item, the producer A uses xQueueSend(queue, buffer, 0);, that is, non-blocking. This means some data items are not transferred from A to be, which is fine in my use-case.

Describe alternatives you've considered
I tried work-arounds using semaphores but this is very tricky to get right without subtle race conditions. If there is a way to implement this using already available synchronization primitives I'd be happy to hear about that!

Ngôn ngữ chính
C
Star
4.6k
Fork
1.6k
Merge trung bình
2 ngày 22 giờ
Pull request đã merge (30 ngày)
4

Chuẩn bị môi trường

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 FreeRTOS/FreeRTOS-Kernel

Tất cả issue của FreeRTOS/FreeRTOS-Kernel

Issue tương tự

Thêm issue về C

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.