summaryrefslogtreecommitdiffstats
path: root/cpukit/posix
diff options
context:
space:
mode:
Diffstat (limited to 'cpukit/posix')
-rw-r--r--cpukit/posix/src/clocknanosleep.c38
-rw-r--r--cpukit/posix/src/prwlocktimedrdlock.c3
-rw-r--r--cpukit/posix/src/prwlocktimedwrlock.c3
-rw-r--r--cpukit/posix/src/semtimedwait.c3
-rw-r--r--cpukit/posix/src/sigtimedwait.c8
5 files changed, 28 insertions, 27 deletions
diff --git a/cpukit/posix/src/clocknanosleep.c b/cpukit/posix/src/clocknanosleep.c
index 588f67a60a..bfb78466df 100644
--- a/cpukit/posix/src/clocknanosleep.c
+++ b/cpukit/posix/src/clocknanosleep.c
@@ -43,11 +43,10 @@ int clock_nanosleep(
struct timespec *rmtp
)
{
- Thread_queue_Context queue_context;
- struct timespec now;
- const struct timespec *end;
- Thread_Control *executing;
- int eno;
+ Thread_queue_Context queue_context;
+ bool absolute;
+ Thread_Control *executing;
+ int eno;
if ( clock_id != CLOCK_REALTIME && clock_id != CLOCK_MONOTONIC ) {
return ENOTSUP;
@@ -60,26 +59,23 @@ int clock_nanosleep(
);
if ( ( flags & TIMER_ABSTIME ) != 0 ) {
- end = rqtp;
+ absolute = true;
+ rmtp = NULL;
} else {
- if ( clock_id == CLOCK_REALTIME ) {
- _Timecounter_Nanotime( &now );
- } else {
- _Timecounter_Nanouptime( &now );
- }
-
- end = _Watchdog_Future_timespec( &now, rqtp );
+ absolute = false;
}
if ( clock_id == CLOCK_REALTIME ) {
_Thread_queue_Context_set_enqueue_timeout_realtime_timespec(
&queue_context,
- end
+ rqtp,
+ absolute
);
} else {
_Thread_queue_Context_set_enqueue_timeout_monotonic_timespec(
&queue_context,
- end
+ rqtp,
+ absolute
);
}
@@ -97,10 +93,11 @@ int clock_nanosleep(
eno = 0;
}
- if ( rmtp != NULL && ( flags & TIMER_ABSTIME ) == 0 ) {
+ if ( rmtp != NULL ) {
#if defined( RTEMS_POSIX_API )
if ( eno == EINTR ) {
struct timespec actual_end;
+ struct timespec planned_end;
if ( clock_id == CLOCK_REALTIME ) {
_Timecounter_Nanotime( &actual_end );
@@ -108,8 +105,13 @@ int clock_nanosleep(
_Timecounter_Nanouptime( &actual_end );
}
- if ( _Timespec_Less_than( &actual_end, end ) ) {
- _Timespec_Subtract( &actual_end, end, rmtp );
+ _Watchdog_Ticks_to_timespec(
+ executing->Timer.Watchdog.expire,
+ &planned_end
+ );
+
+ if ( _Timespec_Less_than( &actual_end, &planned_end ) ) {
+ _Timespec_Subtract( &actual_end, &planned_end, rmtp );
} else {
_Timespec_Set_to_zero( rmtp );
}
diff --git a/cpukit/posix/src/prwlocktimedrdlock.c b/cpukit/posix/src/prwlocktimedrdlock.c
index 79059800bf..809f355359 100644
--- a/cpukit/posix/src/prwlocktimedrdlock.c
+++ b/cpukit/posix/src/prwlocktimedrdlock.c
@@ -37,7 +37,8 @@ int pthread_rwlock_timedrdlock(
_Thread_queue_Context_initialize( &queue_context );
_Thread_queue_Context_set_enqueue_timeout_realtime_timespec(
&queue_context,
- abstime
+ abstime,
+ true
);
status = _CORE_RWLock_Seize_for_reading(
&the_rwlock->RWLock,
diff --git a/cpukit/posix/src/prwlocktimedwrlock.c b/cpukit/posix/src/prwlocktimedwrlock.c
index 9fb9a880a0..614d230ba9 100644
--- a/cpukit/posix/src/prwlocktimedwrlock.c
+++ b/cpukit/posix/src/prwlocktimedwrlock.c
@@ -39,7 +39,8 @@ int pthread_rwlock_timedwrlock(
_Thread_queue_Context_initialize( &queue_context );
_Thread_queue_Context_set_enqueue_timeout_realtime_timespec(
&queue_context,
- abstime
+ abstime,
+ true
);
status = _CORE_RWLock_Seize_for_writing(
&the_rwlock->RWLock,
diff --git a/cpukit/posix/src/semtimedwait.c b/cpukit/posix/src/semtimedwait.c
index 21a8320b50..ae83e90540 100644
--- a/cpukit/posix/src/semtimedwait.c
+++ b/cpukit/posix/src/semtimedwait.c
@@ -60,7 +60,8 @@ int sem_timedwait(
);
_Thread_queue_Context_set_enqueue_timeout_realtime_timespec(
&queue_context,
- abstime
+ abstime,
+ true
);
_Thread_queue_Context_set_ISR_level( &queue_context, level );
_Thread_queue_Enqueue(
diff --git a/cpukit/posix/src/sigtimedwait.c b/cpukit/posix/src/sigtimedwait.c
index 4e2b6c2658..0bdb65fd45 100644
--- a/cpukit/posix/src/sigtimedwait.c
+++ b/cpukit/posix/src/sigtimedwait.c
@@ -76,7 +76,6 @@ int sigtimedwait(
siginfo_t signal_information;
siginfo_t *the_info;
int signo;
- struct timespec uptime;
Thread_queue_Context queue_context;
int error;
@@ -93,13 +92,10 @@ int sigtimedwait(
*/
if ( timeout != NULL ) {
- const struct timespec *end;
-
- _Timecounter_Nanouptime( &uptime );
- end = _Watchdog_Future_timespec( &uptime, timeout );
_Thread_queue_Context_set_enqueue_timeout_monotonic_timespec(
&queue_context,
- end
+ timeout,
+ false
);
} else {
_Thread_queue_Context_set_enqueue_do_nothing_extra( &queue_context );