From ffbee8a6c43141a77801b4ca40a145b3e56faf7a Mon Sep 17 00:00:00 2001 From: Sebastian Huber Date: Mon, 3 Nov 2014 09:18:14 +0100 Subject: Add rtems_bsd_force_select_timeout() --- freebsd/sys/kern/sys_generic.c | 46 +++++++++++++++++++++++++++++++++++++++ rtemsbsd/include/rtems/bsd/util.h | 19 ++++++++++++++++ 2 files changed, 65 insertions(+) diff --git a/freebsd/sys/kern/sys_generic.c b/freebsd/sys/kern/sys_generic.c index fefc94d9..6fc16fc5 100644 --- a/freebsd/sys/kern/sys_generic.c +++ b/freebsd/sys/kern/sys_generic.c @@ -1874,3 +1874,49 @@ selectinit(void *dummy __unused) NULL, NULL, UMA_ALIGN_PTR, 0); mtxpool_select = mtx_pool_create("select mtxpool", 128, MTX_DEF); } +#ifdef __rtems__ +#include + +#include +#include +#include + +#include + +static void +force_select_timeout(Thread_Control *thread) +{ + struct thread *td = rtems_bsd_get_thread(thread); + + if (td != NULL) { + struct seltd *stp = td->td_sel; + + if (thread->Wait.queue == &stp->st_wait.cv_waiters) { + _Thread_queue_Process_timeout(thread); + } + } +} + +rtems_status_code rtems_bsd_force_select_timeout(rtems_id task_id) +{ + Thread_Control *thread; + Objects_Locations location; + + thread = _Thread_Get(task_id, &location); + switch (location) { + case OBJECTS_LOCAL: + force_select_timeout(thread); + _Objects_Put(&thread->Object); + break; +#if defined(RTEMS_MULTIPROCESSING) + case OBJECTS_REMOTE: + _Thread_Dispatch(); + return (RTEMS_ILLEGAL_ON_REMOTE_OBJECT); +#endif + default: + return (RTEMS_INVALID_ID); + } + + return (RTEMS_SUCCESSFUL); +} +#endif /* __rtems__ */ diff --git a/rtemsbsd/include/rtems/bsd/util.h b/rtemsbsd/include/rtems/bsd/util.h index a2cd1e80..86aacf3f 100644 --- a/rtemsbsd/include/rtems/bsd/util.h +++ b/rtemsbsd/include/rtems/bsd/util.h @@ -40,6 +40,8 @@ #include +#include + #ifdef __cplusplus extern "C" { #endif /* __cplusplus */ @@ -77,6 +79,23 @@ rtems_bsd_arp_processor_process( rtems_bsd_arp_processor_context *ctx, rtems_bsd_arp_processor processor, void *arg); +/** + * @brief Forces a select() timeout for the specified task. + * + * In case the specified task waits in a select(), then it is woken up with a + * timeout status, otherwise this call has no effect. + * + * @param[in] task_id The task identifier. + * + * @retval RTEMS_SUCCESSFUL Successful operation. + * @retval RTEMS_INVALID_ID No such task. + * + * @warning This function may go away once the signal support for condition + * variables is implemented. + */ +rtems_status_code +rtems_bsd_force_select_timeout(rtems_id task_id); + #ifdef __cplusplus } #endif /* __cplusplus */ -- cgit v1.2.3