Skip to content

Commit

Permalink
uknetdev: Yield on busy-waiting for transmit
Browse files Browse the repository at this point in the history
Whenever we need to wait for the device/driver to be
ready for sending out another packet, we enter a
busy-wait loop. With this commit, we call
`uk_sched_yield()` while we wait so that other threads
in the system can be executed.

Signed-off-by: Simon Kuenzer <simon.kuenzer@neclab.eu>
  • Loading branch information
skuenzer committed Nov 30, 2021
1 parent 489b19c commit 2e60853
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions uknetdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -213,9 +213,12 @@ static err_t uknetdev_output(struct netif *nf, struct pbuf *p)
UK_ASSERT(nb->len == p->tot_len);

/* Transmit packet */
do {
ret = uk_netdev_tx_one(dev, 0, nb);
while (unlikely(uk_netdev_status_notready(ret))) {
/* Allow other threads to do work and re-try */
uk_sched_yield();
ret = uk_netdev_tx_one(dev, 0, nb);
} while (uk_netdev_status_notready(ret));
}
if (unlikely(ret < 0)) {
LWIP_DEBUGF(NETIF_DEBUG,
("%s: %c%c%u: Failed to send %"PRIu16" bytes\n",
Expand Down

0 comments on commit 2e60853

Please sign in to comment.