00001
00002
00011
00012
00013
00014
00015
00016
00017 #include <l4/thread/thread.h>
00018
00019 #include <l4/dde_linux/dde.h>
00020
00021
00022 #include <linux/sched.h>
00023
00024
00025 #include "internal.h"
00026 #include "__config.h"
00027
00028 static DECLARE_TASK_QUEUE(tq_context);
00029 static DECLARE_WAIT_QUEUE_HEAD(context_task_wq);
00030
00031
00032 int schedule_task(struct tq_struct *task)
00033 {
00034 int ret;
00035
00036 ret = queue_task(task, &tq_context);
00037 wake_up(&context_task_wq);
00038 return ret;
00039 }
00040
00041 static void dde_keventd_thread(void *dummy)
00042 {
00043 struct task_struct *curtask;
00044
00045 if (l4dde_process_add_worker())
00046 Panic("l4dde_process_add_worker() failed");
00047 curtask = current;
00048
00049 DECLARE_WAITQUEUE(wait, curtask);
00050
00051
00052 if (l4thread_started(NULL) < 0)
00053 Panic("keventd thread startup failed!");
00054
00055 LOGd(DEBUG_MSG, "dde_keventd_thread "l4util_idfmt" running.",
00056 l4util_idstr(l4thread_l4_id(l4thread_myself())));
00057
00058 for (;;)
00059 {
00060 set_task_state(curtask, TASK_INTERRUPTIBLE);
00061 add_wait_queue(&context_task_wq, &wait);
00062 if (TQ_ACTIVE(tq_context))
00063 set_task_state(curtask, TASK_RUNNING);
00064 schedule();
00065 remove_wait_queue(&context_task_wq, &wait);
00066 run_task_queue(&tq_context);
00067
00068 }
00069 }
00070
00071 int l4dde_keventd_init(void)
00072 {
00073 int err;
00074 static int _initialized = 0;
00075
00076 if (_initialized)
00077 return 0;
00078
00079
00080 err = l4thread_create_long(L4THREAD_INVALID_ID,
00081 (l4thread_fn_t) dde_keventd_thread,
00082 ".keventd",
00083 L4THREAD_INVALID_SP,
00084 L4THREAD_DEFAULT_SIZE,
00085 L4THREAD_DEFAULT_PRIO,
00086 (void *) 0,
00087 L4THREAD_CREATE_SYNC);
00088
00089 if (err < 0)
00090 return err;
00091
00092 ++_initialized;
00093 return 0;
00094 }