Implement agreed-upon semantics for delay/timeout arguments.

A delay/timeout <=0.0 results in a yield/poll.
A delay/timeout >0.0 is rounded up to 1 tick.
This commit is contained in:
W. Eric Norum
2001-05-18 19:36:03 +00:00
parent 5f07d422fd
commit 83a864997d
3 changed files with 33 additions and 12 deletions
+12 -4
View File
@@ -125,14 +125,22 @@ epicsEventWaitWithTimeout(epicsEventId id, double timeOut)
{
rtems_id sid = (rtems_id)id;
rtems_status_code sc;
rtems_unsigned32 wait;
rtems_interval delay;
extern double rtemsTicksPerSecond_double;
SEMSTAT(1)
delay = timeOut * rtemsTicksPerSecond_double;
if (delay == 0)
delay = 1;
sc = rtems_semaphore_obtain (sid, RTEMS_WAIT, delay);
if (timeOut <= 0.0) {
wait = RTEMS_NO_WAIT;
delay = 0;
}
else {
wait = RTEMS_WAIT;
delay = timeOut * rtemsTicksPerSecond_double;
if (delay == 0)
delay++;
}
sc = rtems_semaphore_obtain (sid, wait, delay);
if (sc == RTEMS_SUCCESSFUL)
return epicsEventWaitOK;
else if (sc == RTEMS_TIMEOUT)
+13 -5
View File
@@ -153,19 +153,27 @@ epicsMutexLockStatus epicsMutexLockWithTimeout(
#ifdef RTEMS_FAST_MUTEX
Semaphore_Control *the_semaphore = (Semaphore_Control *)id;
ISR_Level level;
boolean wait;
rtems_interval delay;
extern double rtemsTicksPerSecond_double;
SEMSTAT(1)
delay = timeOut * rtemsTicksPerSecond_double;
if (delay == 0)
delay = 1;
if (timeOut <= 0.0) {
wait = FALSE;
delay = 0;
}
else {
wait = TRUE;
delay = timeOut * rtemsTicksPerSecond_double;
if (delay == 0)
delay++;
}
_ISR_Disable( level );
_CORE_mutex_Seize(
&the_semaphore->Core_control.mutex,
the_semaphore->Object.id,
1, /* TRUE or FALSE */
delay, /* same as passed to obtain -- ticks */
wait,
delay,
level
);
if (_Thread_Executing->Wait.return_code == 0)
+8 -3
View File
@@ -371,9 +371,14 @@ epicsThreadSleep (double seconds)
rtems_interval delay;
extern double rtemsTicksPerSecond_double;
delay = seconds * rtemsTicksPerSecond_double;
if (delay == 0)
delay++;
if (seconds <= 0.0) {
delay = 0;
}
else {
delay = seconds * rtemsTicksPerSecond_double;
if (delay == 0)
delay++;
}
sc = rtems_task_wake_after (delay);
if(sc != RTEMS_SUCCESSFUL)
errlogPrintf("epicsThreadSleep: %s\n", rtems_status_text (sc));