]> xenbits.xensource.com Git - unikraft/libs/lwip.git/commitdiff
Adopt to latest libuklock, libukmpi changes
authorSimon Kuenzer <simon.kuenzer@neclab.eu>
Wed, 8 May 2019 09:54:53 +0000 (11:54 +0200)
committerFlorian Schmidt <florian.schmidt@neclab.eu>
Mon, 13 May 2019 07:42:05 +0000 (09:42 +0200)
lwip's semaphores are implemented based on semphores provided by
libuklock and lwip's mailboxes are implemented based on mailboxes
provided by libukmpi. The API of both have changed recently;
originally with commit a48d634 ("lib/uklock: Use timeout equal to 0
for trying down a semaphore"): A passed timeout of `0` is now
immediately returning instead of blocking the current thread until the
according event happened.

This patch also depends on the Unikraft patch 734930 ("lib/ukmpi:
Provide blocking uk_mbox_recv()"):
  https://patchwork.unikraft.org/patch/734930/

Signed-off-by: Simon Kuenzer <simon.kuenzer@neclab.eu>
Reviewed-by: Costin Lupu <costin.lupu@cs.pub.ro>
mailbox.c
semaphore.c

index 6fb5fda8e53f6d2446475d67139961948bda5e60..9bc34d8a084af7a8016ad5de32a1a2c52d73fdd6 100644 (file)
--- a/mailbox.c
+++ b/mailbox.c
@@ -130,10 +130,17 @@ u32_t sys_arch_mbox_fetch(sys_mbox_t *mbox, void **msg, u32_t timeout)
 
        UK_ASSERT(sys_mbox_valid(mbox));
 
-       nsret = uk_mbox_recv_to(mbox->mbox, msg,
-                               ukarch_time_msec_to_nsec((__nsec) timeout));
-       if (unlikely(nsret == __NSEC_MAX))
-               return SYS_ARCH_TIMEOUT;
+       if (timeout == 0) {
+               nsret = ukplat_monotonic_clock();
+               uk_mbox_recv(mbox->mbox, msg);
+               nsret = ukplat_monotonic_clock() - nsret;
+       } else {
+               nsret = uk_mbox_recv_to(mbox->mbox, msg,
+                                       ukarch_time_msec_to_nsec((__nsec)
+                                                                timeout));
+               if (unlikely(nsret == __NSEC_MAX))
+                       return SYS_ARCH_TIMEOUT;
+       }
        return (u32_t) ukarch_time_nsec_to_msec(nsret);
 }
 
index 16da316a9aecfad082a62a0088a7758522735c50..e962d4bc2b7cbe9c48c7d728fb0e4973aa102cd4 100644 (file)
@@ -85,10 +85,18 @@ u32_t sys_arch_sem_wait(sys_sem_t *sem, u32_t timeout)
 {
        __nsec nsret;
 
-       nsret = uk_semaphore_down_to(&sem->sem,
-                                    ukarch_time_msec_to_nsec((__nsec)
-                                                             timeout));
-       if (unlikely(nsret == __NSEC_MAX))
-               return SYS_ARCH_TIMEOUT;
+       uk_pr_debug("sys_arch_sem_wait(%p, %"PRIu32")\n", sem, timeout);
+       if (timeout == 0) {
+               nsret = ukplat_monotonic_clock();
+               uk_semaphore_down(&sem->sem);
+               nsret = ukplat_monotonic_clock() - nsret;
+       } else {
+               nsret = uk_semaphore_down_to(&sem->sem,
+                                            ukarch_time_msec_to_nsec((__nsec)
+                                                                     timeout));
+               if (unlikely(nsret == __NSEC_MAX))
+                       return SYS_ARCH_TIMEOUT;
+       }
+
        return (u32_t) ukarch_time_nsec_to_msec(nsret);
 }