[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Minios-devel] [UNIKRAFT PATCH 1/2] lib/uklock: Use timeout equal to 0 for trying down a semaphore
- To: minios-devel@xxxxxxxxxxxxx
- From: Costin Lupu <costin.lupu@xxxxxxxxx>
- Date: Mon, 11 Mar 2019 18:28:41 +0200
- Cc: Florian.Schmidt@xxxxxxxxx, simon.kuenzer@xxxxxxxxx, yuri.volchkov@xxxxxxxxx, sharan.santhanam@xxxxxxxxx
- Delivery-date: Mon, 11 Mar 2019 16:28:56 +0000
- Ironport-phdr: 9a23:bPfrXh8zoW8t1/9uRHKM819IXTAuvvDOBiVQ1KB+0+oUIJqq85mqBkHD//Il1AaPAdyDraodw8Pt8InYEVQa5piAtH1QOLdtbDQizfssogo7HcSeAlf6JvO5JwYzHcBFSUM3tyrjaRsdF8nxfUDdrWOv5jAOBBr/KRB1JuPoEYLOksi7ze+/94DPbwlSmDaxfK55IQmrownWqsQYm5ZpJLwryhvOrHtIeuBWyn1tKFmOgRvy5dq+8YB6/ShItP0v68BPUaPhf6QlVrNYFygpM3o05MLwqxbOSxaE62YGXWUXlhpIBBXF7A3/U5zsvCb2qvZx1S+HNsDwULs6Wymt771zRRHolikJKjA3/mLQhMNygqJWuw6tqwBlzoLIeoyZKOZyc6XAdt0aX2pBWcNRWjRfD4O7dIsPE+sBPeBFpIf7ulsOtQa+DhSrCezzzT9InWP23aw80+g7FQHGwRQgH88VvXvIt9X5Lr8SUf2uw6XS1zXDaOpb1DHg44bLahAsueyAUL1tfcbLykQiFxnJgkuOpYHnJT+Y2PwBv3WU4uZ9T+6iiG4qpxtvrjWhyMogkJTFi40Lxl3C6C532pw6JceiR05+edOkFZxQuDyEOIZuWcMiRn1ouD49yr0bpZ63ZCgKx4ojxx7Yc/GHbY2I7QjiVOaVOzt3mGlldKinhxav6kes0Pf8Vs6s3FZLqCpKjMXMu2gQ2xHc98SLUPhw80e71TqRyQze6PtILE4smareMZEhw7owlpQJsUTEGy/7gFn5jKiNdkU4++io7f7rYrH7pp+EKo95kR3xMr80lsynHOQ3KRICX3Kc+eikzr3s4VX5QKlWjv0xiqTZtZHaJcIapq6+GA9Zy5ss5AihDzi41NQVhn0HLFNeeBKblIjlIV7PL+7+DfulhFSsijhrzejcPrL9GpXNMmTDkLD5cLh9705czxAzzdFF6JJSEL0PPe78Wk/0tNzZExA5Lxe5w+D5B9ph0oMRQ3mADrWHP6PPqVWI/P4gI/GQZI8JvzbwM+Ml5/70gn8jg1Ade7Ol3YANZ3C+AvRmI1+WYXz2jdcECmoKuBQxQ/DuiFKYSjFffWi9X78k7DEhFI2mFZvDRpyqgLGZxye7H5hWZmdAClyWEnfoapuLW/ENaS2MOM9siToEWqa9RI8lzx6hrxX2xKR6LuDM4C0XqYrj1MRp5+3UjRwz9SF0D96c022XUWF0mWcISCM23KB8pkx91EyO0a5mjPNEEdxc/ehGXh0kOp7BnKRGDIX3WwTAeczMRFu4T9GOBTAqUsl309IIJUFnFIaMlBfGigGtGKMUkfSvGYQpuvbX2GPtJsA7z2veyYEqlB8+X8EJL2rw1f03zBTaG4OcyxbRrK2tb6lJhCM=
- Ironport-sdr: tVoTiy6NEfWRiEZcqFBuNANPhG7ljhkY67QWXeLDYfjLDge8nLvk5XEmJ3Wn9bIirc0HQzLcr4 JI7Od7Z+NTgA==
- List-id: Mini-os development list <minios-devel.lists.xenproject.org>
Until now, timeout equal to 0 meant waiting until the semaphore counter
would have got greater than zero, potentially forever. We allow now timeout
equal to 0 to be used when the user wants just to try down the semaphore
and return immediately, in order to be compliant with the behavior of the
sem_timedwait() POSIX function.
Signed-off-by: Costin Lupu <costin.lupu@xxxxxxxxx>
---
lib/uklock/include/uk/semaphore.h | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)
diff --git a/lib/uklock/include/uk/semaphore.h
b/lib/uklock/include/uk/semaphore.h
index dea9a720..2513d441 100644
--- a/lib/uklock/include/uk/semaphore.h
+++ b/lib/uklock/include/uk/semaphore.h
@@ -97,10 +97,7 @@ static inline __nsec uk_semaphore_down_to(struct
uk_semaphore *s,
UK_ASSERT(s);
- if (timeout == 0)
- deadline = 0;
- else
- deadline = then + timeout;
+ deadline = then + timeout;
for (;;) {
uk_waitq_wait_event_deadline(&s->wait, s->count > 0, deadline);
--
2.11.0
_______________________________________________
Minios-devel mailing list
Minios-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/minios-devel
|