-
Notifications
You must be signed in to change notification settings - Fork 124
Open
Labels
releasePart of the next releasePart of the next release
Description
Describe the release item
In Zenoh-Pico's unicast transport, the read thread consumes excessive CPU resources when there is no data to receive. This occurs because the thread is busy-waiting on a non-blocking socket, immediately retrying the read operation in a tight loop. To fix this, I propose adding a short sleep (z_sleep_ms(1)) after an unsuccessful read to allow the CPU to yield to other tasks. This simple change will significantly reduce CPU usage, which is critical for resource-constrained embedded systems.
zenoh-pico\src\transport\unicast\read.c line 358:
size_t to_read = 0;
// Retrieve data
if (!_z_unicast_client_read(ztu, curr_peer, &to_read)) {
// [Proposed Change] Add a small delay to prevent busy-waiting
z_sleep_s(1);
continue;
}
Additionally, I would like to know how a Zenoh-pico client can detect when its TCP connection to a broker has been terminated. What is the proper way to handle this state in the client application?
Metadata
Metadata
Assignees
Labels
releasePart of the next releasePart of the next release