3 #include <linux/config.h>
4 #include <linux/version.h>
6 #include <linux/kernel.h>
7 #include <linux/sched.h>
9 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,40))
10 #include <linux/tqueue.h>
11 #define tasklet_struct tq_struct
13 #include <linux/devfs_fs_kernel.h>
16 #include <linux/wait.h>
17 #include <linux/interrupt.h>
19 #include <asm/unistd.h>
20 #include <asm/semaphore.h>
22 /* a structure to store all information we need
24 typedef struct kthread_struct
28 /* Linux task structure of thread */
29 struct task_struct *thread;
30 /* Task queue/Tasklet need to launch thread */
31 struct tasklet_struct tq;
32 /* function to be started as thread */
33 void (*function) (struct kthread_struct *kthread);
34 /* semaphore needed on start and creation of thread. */
35 struct semaphore startstop_sem;
39 /* queue thread is waiting on. Gets initialized by
40 init_kthread, can be used by thread itself.
42 wait_queue_head_t queue;
43 /* flag to tell thread whether to die or not.
44 When the thread receives a signal, it must check
45 the value of terminate and call exit_kthread and terminate
49 /* additional data to pass to kernel thread */
55 /* start new kthread (called by creator) */
56 void start_kthread(void (*func)(kthread_t *), kthread_t *kthread);
58 /* stop a running thread (called by "killer") */
59 void stop_kthread(kthread_t *kthread);
61 /* setup thread environment (called by new thread) */
62 void init_kthread(kthread_t *kthread, char *name);
64 /* cleanup thread environment (called by thread upon receiving termination signal) */
65 void exit_kthread(kthread_t *kthread);