Mathias Zenger wrote:
...
if (timeout> 0) {
/* Create a timer and pass it the address of our flag */
sys_timeout(timeout, sswt_handler,&sswt_cb);
}
sys_sem_wait(sem);
...
As far as I see sys_sem_wait() does a call to sys_arch_sem_wait(). The
passed semaphore is the same:
...
timeouts = sys_arch_timeouts();
if (!timeouts || !timeouts->next) {
sys_arch_sem_wait(sem, 0);
} else {
if (timeouts->next->time> 0) {
time = sys_arch_sem_wait(sem, timeouts->next->time);
} else {
time = SYS_ARCH_TIMEOUT;
}
...
Here I have the problem that it calls sys_arch_sem_wait(sem, 0) due to the
fact that timeouts->next == 0. This leads me to the assumption that the
timer was not correctly handled/registered in sys_timeout(timeout,
sswt_handler,&sswt_cb). Otherwise the timouts list from sys_arch_timeouts()
should contain my timeout??
Yes it should. You could re-check whether !timeouts or !timeouts->next
triggers the inifite wait, but none if it should be true since the code
above should have registered a timeout (sys_timeout(...)). You might
want to check whether you ran out of resources (MEMP_SYS_TIMEOUT, I
guess). Another reason for this to fail is that (up to 1.3.2) the
port-defined function sys_arch_timeouts() must return a dedicated
pointer *per thread*, which has often been done wrong in ports I have seen.
Looking at sys_arch_sem_wait() I see a comment which explains the behaviour:
// If timeout=0, then the function should block indefinitely.
That's exactly not what I want!
Yes it is, but timeout should not be zero here: The code works like that:
- sys_sem_wait_timeout() adds a timeout using sys_timeout
- sys_timeout calls sys_arch_timeouts() and adds a new MEMP_SYS_TIMEOUT
to the list returned by that function
- sys_sem_wait() calls sys_arch_timeouts() again and checks the
per-thread timeout list, finds the first timeout with the value
specified above and
- call sys_arch_sem_wait() with that timeout
Somewhere in these steps seems to be an error, and you might want to
debug it and check against the above description to find it.
Oh, and by the way: That code has already been simplified a lot in CVS
HEAD since I found it much too complicated. But it has been in there for
a while and you are using 1.3.0, so....
Simon
_______________________________________________
lwip-users mailing list
lwip-users@nongnu.org
http://lists.nongnu.org/mailman/listinfo/lwip-users