mirror of
https://git.rtems.org/rtems-libbsd/
synced 2025-10-14 15:20:09 +08:00
SLEEPQUEUE(9): Port to RTEMS
This commit is contained in:
@@ -43,20 +43,11 @@
|
||||
#include <rtems/bsd/sys/param.h>
|
||||
#include <rtems/bsd/sys/types.h>
|
||||
#include <sys/proc.h>
|
||||
#include <sys/queue.h>
|
||||
|
||||
#include <rtems/score/threadq.h>
|
||||
#include <rtems.h>
|
||||
|
||||
#define BSD_TASK_NAME rtems_build_name('_', 'B', 'S', 'D')
|
||||
|
||||
struct sleepqueue {
|
||||
Thread_queue_Control sq_blocked;
|
||||
LIST_ENTRY(sleepqueue) sq_hash;
|
||||
LIST_HEAD(, sleepqueue) sq_free;
|
||||
void *sq_wchan;
|
||||
};
|
||||
|
||||
struct thread *
|
||||
rtems_bsd_get_thread(const Thread_Control *thread);
|
||||
|
||||
|
@@ -1 +0,0 @@
|
||||
/* EMPTY */
|
@@ -49,6 +49,7 @@
|
||||
#include <sys/kthread.h>
|
||||
#include <sys/malloc.h>
|
||||
#include <sys/selinfo.h>
|
||||
#include <sys/sleepqueue.h>
|
||||
|
||||
#include <rtems/bsd/bsd.h>
|
||||
|
||||
@@ -100,23 +101,14 @@ 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);
|
||||
struct sleepqueue *sq = sleepq_alloc();
|
||||
|
||||
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);
|
||||
sleepq_free(sq);
|
||||
td = NULL;
|
||||
}
|
||||
|
||||
@@ -185,7 +177,7 @@ rtems_bsd_extension_thread_delete(
|
||||
|
||||
if (td != NULL) {
|
||||
seltdfini(td);
|
||||
free(td->td_sleepqueue, M_TEMP);
|
||||
sleepq_free(td->td_sleepqueue);
|
||||
free(td, M_TEMP);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user