From 2e6085367e475d203064a768473b49a120bb1771 Mon Sep 17 00:00:00 2001 From: Simon Kuenzer Date: Tue, 9 Nov 2021 17:40:02 +0100 Subject: [PATCH] uknetdev: Yield on busy-waiting for transmit 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 --- uknetdev.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/uknetdev.c b/uknetdev.c index 1577e23..acdadca 100644 --- a/uknetdev.c +++ b/uknetdev.c @@ -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",