]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blob - include/linux/freezer.h
[PATCH] swsusp: thaw userspace and kernel space separately
[linux-2.6-omap-h63xx.git] / include / linux / freezer.h
1 /* Freezer declarations */
2
3 #define FREEZER_KERNEL_THREADS 0
4 #define FREEZER_ALL_THREADS 1
5
6 #ifdef CONFIG_PM
7 /*
8  * Check if a process has been frozen
9  */
10 static inline int frozen(struct task_struct *p)
11 {
12         return p->flags & PF_FROZEN;
13 }
14
15 /*
16  * Check if there is a request to freeze a process
17  */
18 static inline int freezing(struct task_struct *p)
19 {
20         return p->flags & PF_FREEZE;
21 }
22
23 /*
24  * Request that a process be frozen
25  * FIXME: SMP problem. We may not modify other process' flags!
26  */
27 static inline void freeze(struct task_struct *p)
28 {
29         p->flags |= PF_FREEZE;
30 }
31
32 /*
33  * Sometimes we may need to cancel the previous 'freeze' request
34  */
35 static inline void do_not_freeze(struct task_struct *p)
36 {
37         p->flags &= ~PF_FREEZE;
38 }
39
40 /*
41  * Wake up a frozen process
42  */
43 static inline int thaw_process(struct task_struct *p)
44 {
45         if (frozen(p)) {
46                 p->flags &= ~PF_FROZEN;
47                 wake_up_process(p);
48                 return 1;
49         }
50         return 0;
51 }
52
53 /*
54  * freezing is complete, mark process as frozen
55  */
56 static inline void frozen_process(struct task_struct *p)
57 {
58         p->flags = (p->flags & ~PF_FREEZE) | PF_FROZEN;
59 }
60
61 extern void refrigerator(void);
62 extern int freeze_processes(void);
63 #define thaw_processes() do { thaw_some_processes(FREEZER_ALL_THREADS); } while(0)
64 #define thaw_kernel_threads() do { thaw_some_processes(FREEZER_KERNEL_THREADS); } while(0)
65
66 static inline int try_to_freeze(void)
67 {
68         if (freezing(current)) {
69                 refrigerator();
70                 return 1;
71         } else
72                 return 0;
73 }
74
75 extern void thaw_some_processes(int all);
76
77 #else
78 static inline int frozen(struct task_struct *p) { return 0; }
79 static inline int freezing(struct task_struct *p) { return 0; }
80 static inline void freeze(struct task_struct *p) { BUG(); }
81 static inline int thaw_process(struct task_struct *p) { return 1; }
82 static inline void frozen_process(struct task_struct *p) { BUG(); }
83
84 static inline void refrigerator(void) {}
85 static inline int freeze_processes(void) { BUG(); return 0; }
86 static inline void thaw_processes(void) {}
87
88 static inline int try_to_freeze(void) { return 0; }
89
90
91 #endif