Rev 4125 | Rev 5272 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
5270 | serge | 1 | /* |
2 | * workqueue.h --- work queue handling for Linux. |
||
3 | */ |
||
4 | |||
3482 | Serge | 5 | #ifndef _LINUX_WORKQUEUE_H |
6 | #define _LINUX_WORKQUEUE_H |
||
7 | |||
8 | #include |
||
5270 | serge | 9 | #include |
10 | #include |
||
11 | #include |
||
12 | |||
3482 | Serge | 13 | #include |
5270 | serge | 14 | struct workqueue_struct; |
3482 | Serge | 15 | |
16 | struct work_struct; |
||
17 | typedef void (*work_func_t)(struct work_struct *work); |
||
5270 | serge | 18 | void __stdcall delayed_work_timer_fn(unsigned long __data); |
3482 | Serge | 19 | |
20 | /* |
||
21 | * Workqueue flags and constants. For details, please refer to |
||
22 | * Documentation/workqueue.txt. |
||
23 | */ |
||
24 | enum { |
||
25 | WQ_NON_REENTRANT = 1 << 0, /* guarantee non-reentrance */ |
||
26 | WQ_UNBOUND = 1 << 1, /* not bound to any cpu */ |
||
27 | WQ_FREEZABLE = 1 << 2, /* freeze during suspend */ |
||
28 | WQ_MEM_RECLAIM = 1 << 3, /* may be used for memory reclaim */ |
||
29 | WQ_HIGHPRI = 1 << 4, /* high priority */ |
||
30 | WQ_CPU_INTENSIVE = 1 << 5, /* cpu instensive workqueue */ |
||
31 | |||
32 | WQ_DRAINING = 1 << 6, /* internal: workqueue is draining */ |
||
33 | WQ_RESCUER = 1 << 7, /* internal: workqueue has rescuer */ |
||
34 | |||
35 | WQ_MAX_ACTIVE = 512, /* I like 512, better ideas? */ |
||
36 | WQ_MAX_UNBOUND_PER_CPU = 4, /* 4 * #cpus for unbound wq */ |
||
37 | WQ_DFL_ACTIVE = WQ_MAX_ACTIVE / 2, |
||
38 | }; |
||
39 | |||
40 | |||
41 | struct workqueue_struct { |
||
42 | spinlock_t lock; |
||
43 | struct list_head worklist; |
||
44 | struct list_head delayed_worklist; |
||
45 | }; |
||
46 | |||
47 | struct work_struct { |
||
48 | struct list_head entry; |
||
49 | struct workqueue_struct *data; |
||
50 | work_func_t func; |
||
5270 | serge | 51 | #ifdef CONFIG_LOCKDEP |
52 | struct lockdep_map lockdep_map; |
||
53 | #endif |
||
3482 | Serge | 54 | }; |
55 | |||
56 | struct delayed_work { |
||
57 | struct work_struct work; |
||
58 | unsigned int delay; |
||
59 | }; |
||
60 | |||
61 | static inline struct delayed_work *to_delayed_work(struct work_struct *work) |
||
62 | { |
||
63 | return container_of(work, struct delayed_work, work); |
||
64 | } |
||
65 | |||
66 | extern struct workqueue_struct *system_wq; |
||
67 | |||
68 | void run_workqueue(struct workqueue_struct *cwq); |
||
69 | |||
70 | struct workqueue_struct *alloc_workqueue_key(const char *fmt, |
||
71 | unsigned int flags, int max_active); |
||
72 | |||
73 | |||
74 | #define alloc_ordered_workqueue(fmt, flags, args...) \ |
||
75 | alloc_workqueue(fmt, WQ_UNBOUND | (flags), 1, ##args) |
||
76 | |||
4125 | Serge | 77 | bool queue_work(struct workqueue_struct *wq, struct work_struct *work); |
3482 | Serge | 78 | int queue_delayed_work(struct workqueue_struct *wq, |
79 | struct delayed_work *dwork, unsigned long delay); |
||
80 | |||
81 | bool schedule_delayed_work(struct delayed_work *dwork, unsigned long delay); |
||
82 | |||
83 | |||
84 | #define INIT_WORK(_work, _func) \ |
||
85 | do { \ |
||
86 | INIT_LIST_HEAD(&(_work)->entry); \ |
||
87 | (_work)->func = _func; \ |
||
88 | } while (0) |
||
89 | |||
90 | |||
91 | #define INIT_DELAYED_WORK(_work, _func) \ |
||
92 | do { \ |
||
93 | INIT_LIST_HEAD(&(_work)->work.entry); \ |
||
94 | (_work)->work.func = _func; \ |
||
95 | } while (0) |
||
96 | |||
4125 | Serge | 97 | static inline bool schedule_work(struct work_struct *work) |
98 | { |
||
99 | return queue_work(system_wq, work); |
||
100 | } |
||
3482 | Serge | 101 | |
102 | |||
103 | #endif /* _LINUX_WORKQUEUE_H */><>><>><>><>><>><>><>><> |