]> rtime.felk.cvut.cz Git - lincan.git/blob - lincan/include/kthread.h
The first round of I/O space pointers separation.
[lincan.git] / lincan / include / kthread.h
1 #ifndef _KTHREAD_H
2 #define _KTHREAD_H
3 #include <linux/version.h>
4 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,17))
5 #include <linux/config.h>
6 #endif
7
8 #include <linux/kernel.h>
9 #include <linux/sched.h>
10
11 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,40))
12   #include <linux/tqueue.h>
13   #define tasklet_struct tq_struct
14 #else
15   #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,17))
16     #include <linux/devfs_fs_kernel.h>
17   #endif
18 #endif
19
20 #include <linux/wait.h>
21 #include <linux/interrupt.h>
22
23 #include <asm/unistd.h>
24 #include <asm/semaphore.h>
25
26 /* a structure to store all information we need
27    for our thread */
28 typedef struct kthread_struct
29 {
30         /* private data */
31
32         /* Linux task structure of thread */
33         struct task_struct *thread;
34         /* Task queue/Tasklet need to launch thread */
35         struct tasklet_struct tq;
36         /* function to be started as thread */
37         void (*function) (struct kthread_struct *kthread);
38         /* semaphore needed on start and creation of thread. */
39         struct semaphore startstop_sem;
40
41         /* public data */
42
43         /* queue thread is waiting on. Gets initialized by
44            init_kthread, can be used by thread itself.
45         */
46         wait_queue_head_t queue;
47         /* flag to tell thread whether to die or not.
48            When the thread receives a signal, it must check
49            the value of terminate and call exit_kthread and terminate
50            if set.
51         */
52         int terminate;
53         /* additional data to pass to kernel thread */
54         void *arg;
55 } kthread_t;
56
57 /* prototypes */
58
59 /* start new kthread (called by creator) */
60 void start_kthread(void (*func)(kthread_t *), kthread_t *kthread);
61
62 /* stop a running thread (called by "killer") */
63 void stop_kthread(kthread_t *kthread);
64
65 /* setup thread environment (called by new thread) */
66 void init_kthread(kthread_t *kthread, char *name);
67
68 /* cleanup thread environment (called by thread upon receiving termination signal) */
69 void exit_kthread(kthread_t *kthread);
70
71 #endif