diff options
author | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2013-10-23 09:47:09 +0200 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2013-10-31 13:18:50 +0100 |
commit | f9c271459034e777d586f589af90deb9b7acd5a0 (patch) | |
tree | 2065e9400ad6dc3175fb2e5230282c2cf6c6b950 /rtemsbsd/rtems/rtems-bsd-thread.c | |
parent | Rename file to reflect FreeBSD origin (diff) | |
download | rtems-libbsd-f9c271459034e777d586f589af90deb9b7acd5a0.tar.bz2 |
SLEEP(8): New implementation
Diffstat (limited to 'rtemsbsd/rtems/rtems-bsd-thread.c')
-rw-r--r-- | rtemsbsd/rtems/rtems-bsd-thread.c | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/rtemsbsd/rtems/rtems-bsd-thread.c b/rtemsbsd/rtems/rtems-bsd-thread.c index cbf33cf1..b3bdb842 100644 --- a/rtemsbsd/rtems/rtems-bsd-thread.c +++ b/rtemsbsd/rtems/rtems-bsd-thread.c @@ -49,8 +49,12 @@ #include <sys/malloc.h> #include <sys/selinfo.h> -#include <rtems/score/threadimpl.h> #include <rtems/score/objectimpl.h> +#include <rtems/score/statesimpl.h> +#include <rtems/score/threaddispatch.h> +#include <rtems/score/thread.h> +#include <rtems/score/threadimpl.h> +#include <rtems/score/threadqimpl.h> RTEMS_CHAIN_DEFINE_EMPTY(rtems_bsd_thread_chain); @@ -91,9 +95,24 @@ struct thread * rtems_bsd_thread_create(Thread_Control *thread, int wait) { struct thread *td = malloc(sizeof(*td), M_TEMP, M_ZERO | wait); + struct sleepqueue *sq = malloc(sizeof(*sq), M_TEMP, wait); - if (td != NULL) { + if (td != NULL && sq != NULL) { td->td_thread = thread; + td->td_sleepqueue = sq; + + LIST_INIT(&sq->sq_free); + + _Thread_queue_Initialize( + &sq->sq_blocked, + THREAD_QUEUE_DISCIPLINE_PRIORITY, + STATES_WAITING_FOR_BSD_WAKEUP, + EWOULDBLOCK + ); + } else { + free(td, M_TEMP); + free(sq, M_TEMP); + td = NULL; } thread->extensions[rtems_bsd_extension_index] = td; @@ -167,6 +186,7 @@ rtems_bsd_extension_thread_delete( rtems_chain_explicit_extract(&rtems_bsd_thread_chain, &td->td_node); } + free(td->td_sleepqueue, M_TEMP); free(td, M_TEMP); } } |