3 #include <linux/version.h>
4 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,17))
5 #include <linux/config.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
15 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,17))
16 #include <linux/devfs_fs_kernel.h>
20 #include <linux/wait.h>
21 #include <linux/interrupt.h>
23 #include <asm/unistd.h>
25 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,27))
26 #include <asm/semaphore.h>
28 #include <linux/semaphore.h>
31 /* a structure to store all information we need
33 typedef struct kthread_struct
37 /* Linux task structure of thread */
38 struct task_struct *thread;
39 /* Task queue/Tasklet need to launch thread */
40 struct tasklet_struct tq;
41 /* function to be started as thread */
42 void (*function) (struct kthread_struct *kthread);
43 /* semaphore needed on start and creation of thread. */
44 struct semaphore startstop_sem;
48 /* queue thread is waiting on. Gets initialized by
49 init_kthread, can be used by thread itself.
51 wait_queue_head_t queue;
52 /* flag to tell thread whether to die or not.
53 When the thread receives a signal, it must check
54 the value of terminate and call exit_kthread and terminate
58 /* additional data to pass to kernel thread */
64 /* start new kthread (called by creator) */
65 void start_kthread(void (*func)(kthread_t *), kthread_t *kthread);
67 /* stop a running thread (called by "killer") */
68 void stop_kthread(kthread_t *kthread);
70 /* setup thread environment (called by new thread) */
71 void init_kthread(kthread_t *kthread, char *name);
73 /* cleanup thread environment (called by thread upon receiving termination signal) */
74 void exit_kthread(kthread_t *kthread);