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