mirror of
https://github.com/lwip-tcpip/lwip.git
synced 2025-01-27 12:35:26 +00:00
Made lwip timeout measurements accurate by no longer returning 1 millisecond
whenever sys_arch_mbox_wait() and sys_arch_sem_wait() get a message or semaphore immediately. Updated documentation for this change. Unix port and Coldfire port have been updated.
This commit is contained in:
parent
c4ff244c4e
commit
2e0829fb5a
@ -1,4 +1,4 @@
|
|||||||
sys_arch interface for lwIP 0.5
|
sys_arch interface for lwIP 0.6++
|
||||||
|
|
||||||
Author: Adam Dunkels
|
Author: Adam Dunkels
|
||||||
|
|
||||||
@ -60,15 +60,11 @@ The following functions must be implemented by the sys_arch:
|
|||||||
only be blocked for the specified time (measured in
|
only be blocked for the specified time (measured in
|
||||||
milliseconds).
|
milliseconds).
|
||||||
|
|
||||||
If the timeout argument is non-zero, the return value is the amount
|
If the timeout argument is non-zero, the return value is the number of
|
||||||
of time spent waiting for the semaphore to be signaled. If the
|
milliseconds spent waiting for the semaphore to be signaled. If the
|
||||||
semaphore wasn't signaled within the specified time, the return
|
semaphore wasn't signaled within the specified time, the return value is
|
||||||
value is zero. If the thread didn't have to wait for the semaphore
|
0xffffffff. If the thread didn't have to wait for the semaphore (i.e., it
|
||||||
(i.e., it was already signaled), care must be taken to ensure that
|
was already signaled), the function may return zero.
|
||||||
the function does not return a zero value since this is used to
|
|
||||||
indicate that a timeout occured. A suitable way to implement this is
|
|
||||||
to check if the time spent waiting is zero and if so, the value 1 is
|
|
||||||
returned.
|
|
||||||
|
|
||||||
Notice that lwIP implements a function with a similar name,
|
Notice that lwIP implements a function with a similar name,
|
||||||
sys_sem_wait(), that uses the sys_arch_sem_wait() function.
|
sys_sem_wait(), that uses the sys_arch_sem_wait() function.
|
||||||
@ -124,7 +120,8 @@ to be implemented as well:
|
|||||||
|
|
||||||
Starts a new thread with priority "prio" that will begin its execution in the
|
Starts a new thread with priority "prio" that will begin its execution in the
|
||||||
function "thread()". The "arg" argument will be passed as an argument to the
|
function "thread()". The "arg" argument will be passed as an argument to the
|
||||||
thread() function. The id of the new thread is returned.
|
thread() function. The id of the new thread is returned. Both the id and
|
||||||
|
the priority are system dependent.
|
||||||
|
|
||||||
- sys_prot_t sys_arch_protect(void)
|
- sys_prot_t sys_arch_protect(void)
|
||||||
|
|
||||||
|
@ -64,11 +64,11 @@ sys_mbox_fetch(sys_mbox_t mbox, void **msg)
|
|||||||
if(timeouts->next->time > 0) {
|
if(timeouts->next->time > 0) {
|
||||||
time = sys_arch_mbox_fetch(mbox, msg, timeouts->next->time);
|
time = sys_arch_mbox_fetch(mbox, msg, timeouts->next->time);
|
||||||
} else {
|
} else {
|
||||||
time = 0;
|
time = 0xffffffff;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(time == 0) {
|
if(time == 0xffffffff) {
|
||||||
/* If time == 0, a timeout occured before a message could be
|
/* If time == 0xffffffff, a timeout occured before a message could be
|
||||||
fetched. We should now call the timeout handler and
|
fetched. We should now call the timeout handler and
|
||||||
deallocate the memory allocated for the timeout. */
|
deallocate the memory allocated for the timeout. */
|
||||||
tmptimeout = timeouts->next;
|
tmptimeout = timeouts->next;
|
||||||
@ -84,9 +84,9 @@ sys_mbox_fetch(sys_mbox_t mbox, void **msg)
|
|||||||
/* We try again to fetch a message from the mbox. */
|
/* We try again to fetch a message from the mbox. */
|
||||||
goto again;
|
goto again;
|
||||||
} else {
|
} else {
|
||||||
/* If time > 0, a message was received before the timeout
|
/* If time != 0xffffffff, a message was received before the timeout
|
||||||
occured. The time variable is set to the number of
|
occured. The time variable is set to the number of
|
||||||
microseconds we waited for the message. */
|
milliseconds we waited for the message. */
|
||||||
if(time <= timeouts->next->time) {
|
if(time <= timeouts->next->time) {
|
||||||
timeouts->next->time -= time;
|
timeouts->next->time -= time;
|
||||||
} else {
|
} else {
|
||||||
@ -119,11 +119,11 @@ sys_sem_wait(sys_sem_t sem)
|
|||||||
if(timeouts->next->time > 0) {
|
if(timeouts->next->time > 0) {
|
||||||
time = sys_arch_sem_wait(sem, timeouts->next->time);
|
time = sys_arch_sem_wait(sem, timeouts->next->time);
|
||||||
} else {
|
} else {
|
||||||
time = 0;
|
time = 0xffffffff;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(time == 0) {
|
if(time == 0xffffffff) {
|
||||||
/* If time == 0, a timeout occured before a message could be
|
/* If time == 0xffffffff, a timeout occured before a message could be
|
||||||
fetched. We should now call the timeout handler and
|
fetched. We should now call the timeout handler and
|
||||||
deallocate the memory allocated for the timeout. */
|
deallocate the memory allocated for the timeout. */
|
||||||
tmptimeout = timeouts->next;
|
tmptimeout = timeouts->next;
|
||||||
@ -140,9 +140,9 @@ sys_sem_wait(sys_sem_t sem)
|
|||||||
/* We try again to fetch a message from the mbox. */
|
/* We try again to fetch a message from the mbox. */
|
||||||
goto again;
|
goto again;
|
||||||
} else {
|
} else {
|
||||||
/* If time > 0, a message was received before the timeout
|
/* If time != 0xffffffff, a message was received before the timeout
|
||||||
occured. The time variable is set to the number of
|
occured. The time variable is set to the number of
|
||||||
microseconds we waited for the message. */
|
milliseconds we waited for the message. */
|
||||||
if(time <= timeouts->next->time) {
|
if(time <= timeouts->next->time) {
|
||||||
timeouts->next->time -= time;
|
timeouts->next->time -= time;
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user