69 |
|
|
70 |
if (time == SYS_ARCH_TIMEOUT) { |
if (time == SYS_ARCH_TIMEOUT) { |
71 |
/* If time == SYS_ARCH_TIMEOUT, a timeout occured before a message |
/* If time == SYS_ARCH_TIMEOUT, a timeout occured before a message |
72 |
could be fetched. We should now call the timeout handler and |
could be fetched. We should now call the timeout handler and |
73 |
deallocate the memory allocated for the timeout. */ |
deallocate the memory allocated for the timeout. */ |
74 |
tmptimeout = timeouts->next; |
tmptimeout = timeouts->next; |
75 |
timeouts->next = tmptimeout->next; |
timeouts->next = tmptimeout->next; |
76 |
h = tmptimeout->h; |
h = tmptimeout->h; |
78 |
memp_free(MEMP_SYS_TIMEOUT, tmptimeout); |
memp_free(MEMP_SYS_TIMEOUT, tmptimeout); |
79 |
if (h != NULL) { |
if (h != NULL) { |
80 |
DEBUGF(SYS_DEBUG, ("smf calling h=%p(%p)\n", (void *)h, (void *)arg)); |
DEBUGF(SYS_DEBUG, ("smf calling h=%p(%p)\n", (void *)h, (void *)arg)); |
81 |
h(arg); |
h(arg); |
82 |
} |
} |
83 |
|
|
84 |
/* We try again to fetch a message from the mbox. */ |
/* We try again to fetch a message from the mbox. */ |
85 |
goto again; |
goto again; |
86 |
} else { |
} else { |
87 |
/* If time != SYS_ARCH_TIMEOUT, a message was received before the timeout |
/* If time != SYS_ARCH_TIMEOUT, a message was received before the timeout |
88 |
occured. The time variable is set to the number of |
occured. The time variable is set to the number of |
89 |
milliseconds we waited for the message. */ |
milliseconds we waited for the message. */ |
90 |
if (time <= timeouts->next->time) { |
if (time <= timeouts->next->time) { |
91 |
timeouts->next->time -= time; |
timeouts->next->time -= time; |
92 |
} else { |
} else { |
93 |
timeouts->next->time = 0; |
timeouts->next->time = 0; |
94 |
} |
} |
95 |
} |
} |
96 |
|
|
124 |
|
|
125 |
if (time == SYS_ARCH_TIMEOUT) { |
if (time == SYS_ARCH_TIMEOUT) { |
126 |
/* If time == SYS_ARCH_TIMEOUT, a timeout occured before a message |
/* If time == SYS_ARCH_TIMEOUT, a timeout occured before a message |
127 |
could be fetched. We should now call the timeout handler and |
could be fetched. We should now call the timeout handler and |
128 |
deallocate the memory allocated for the timeout. */ |
deallocate the memory allocated for the timeout. */ |
129 |
tmptimeout = timeouts->next; |
tmptimeout = timeouts->next; |
130 |
timeouts->next = tmptimeout->next; |
timeouts->next = tmptimeout->next; |
131 |
h = tmptimeout->h; |
h = tmptimeout->h; |
132 |
arg = tmptimeout->arg; |
arg = tmptimeout->arg; |
133 |
memp_free(MEMP_SYS_TIMEOUT, tmptimeout); |
memp_free(MEMP_SYS_TIMEOUT, tmptimeout); |
134 |
if (h != NULL) { |
if (h != NULL) { |
135 |
DEBUGF(SYS_DEBUG, ("ssw h=%p(%p)\n", (void *)h, (void *)arg)); |
DEBUGF(SYS_DEBUG, ("ssw h=%p(%p)\n", (void *)h, (void *)arg)); |
136 |
h(arg); |
h(arg); |
137 |
} |
} |
138 |
|
|
139 |
|
|
140 |
/* We try again to fetch a message from the mbox. */ |
/* We try again to fetch a message from the mbox. */ |
141 |
goto again; |
goto again; |
142 |
} else { |
} else { |
143 |
/* If time != SYS_ARCH_TIMEOUT, a message was received before the timeout |
/* If time != SYS_ARCH_TIMEOUT, a message was received before the timeout |
144 |
occured. The time variable is set to the number of |
occured. The time variable is set to the number of |
145 |
milliseconds we waited for the message. */ |
milliseconds we waited for the message. */ |
146 |
if (time <= timeouts->next->time) { |
if (time <= timeouts->next->time) { |
147 |
timeouts->next->time -= time; |
timeouts->next->time -= time; |
148 |
} else { |
} else { |
149 |
timeouts->next->time = 0; |
timeouts->next->time = 0; |
150 |
} |
} |
151 |
} |
} |
152 |
|
|
186 |
for(t = timeouts->next; t != NULL; t = t->next) { |
for(t = timeouts->next; t != NULL; t = t->next) { |
187 |
timeout->time -= t->time; |
timeout->time -= t->time; |
188 |
if (t->next == NULL || |
if (t->next == NULL || |
189 |
t->next->time > timeout->time) { |
t->next->time > timeout->time) { |
190 |
if (t->next != NULL) { |
if (t->next != NULL) { |
191 |
t->next->time -= timeout->time; |
t->next->time -= timeout->time; |
192 |
} |
} |
193 |
timeout->next = t->next; |
timeout->next = t->next; |
194 |
t->next = timeout; |
t->next = timeout; |
195 |
break; |
break; |
196 |
} |
} |
197 |
} |
} |
198 |
} |
} |
282 |
void |
void |
283 |
sys_msleep(u32_t ms) |
sys_msleep(u32_t ms) |
284 |
{ |
{ |
285 |
sys_sem_t delaysem = sys_sem_new(0); |
sys_sem_t delaysem = sys_sem_new(0); |
286 |
|
|
287 |
sys_sem_wait_timeout(delaysem, ms); |
sys_sem_wait_timeout(delaysem, ms); |
288 |
|
|
289 |
sys_sem_free(delaysem); |
sys_sem_free(delaysem); |
290 |
} |
} |
291 |
/*-----------------------------------------------------------------------------------*/ |
/*-----------------------------------------------------------------------------------*/ |
292 |
|
|