From 5e9f9328696f8fb2a37b425112036cff5f319ee9 Mon Sep 17 00:00:00 2001 From: Stefan Lankes Date: Mon, 22 Aug 2016 16:51:09 +0200 Subject: [PATCH] use busy waiting for receiving the IP address => reduce the latency --- hermit/kernel/main.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/hermit/kernel/main.c b/hermit/kernel/main.c index 9a4e4ba5d..002394b97 100644 --- a/hermit/kernel/main.c +++ b/hermit/kernel/main.c @@ -228,7 +228,19 @@ success: int mscnt = 0; /* wait for ip address */ while(!default_netif.ip_addr.addr) { + uint64_t end_tsc, start_tsc = rdtsc(); + +#if 1 + do { + if (default_netif.ip_addr.addr) + return 0; + check_workqueues(); + end_tsc = rdtsc(); + } while(((end_tsc - start_tsc) / (get_cpu_frequency() * 1000)) < DHCP_FINE_TIMER_MSECS); +#else sys_msleep(DHCP_FINE_TIMER_MSECS); +#endif + dhcp_fine_tmr(); mscnt += DHCP_FINE_TIMER_MSECS; if (mscnt >= DHCP_COARSE_TIMER_SECS*1000) { @@ -238,7 +250,6 @@ success: } } - return 0; }