aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/freezer.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux/freezer.h')
-rw-r--r--include/linux/freezer.h90
1 files changed, 90 insertions, 0 deletions
diff --git a/include/linux/freezer.h b/include/linux/freezer.h
new file mode 100644
index 000000000000..5e75e26d4787
--- /dev/null
+++ b/include/linux/freezer.h
@@ -0,0 +1,90 @@
1/* Freezer declarations */
2
3#include <linux/sched.h>
4
5#ifdef CONFIG_PM
6/*
7 * Check if a process has been frozen
8 */
9static inline int frozen(struct task_struct *p)
10{
11 return p->flags & PF_FROZEN;
12}
13
14/*
15 * Check if there is a request to freeze a process
16 */
17static inline int freezing(struct task_struct *p)
18{
19 return test_tsk_thread_flag(p, TIF_FREEZE);
20}
21
22/*
23 * Request that a process be frozen
24 */
25static inline void freeze(struct task_struct *p)
26{
27 set_tsk_thread_flag(p, TIF_FREEZE);
28}
29
30/*
31 * Sometimes we may need to cancel the previous 'freeze' request
32 */
33static inline void do_not_freeze(struct task_struct *p)
34{
35 clear_tsk_thread_flag(p, TIF_FREEZE);
36}
37
38/*
39 * Wake up a frozen process
40 */
41static inline int thaw_process(struct task_struct *p)
42{
43 if (frozen(p)) {
44 p->flags &= ~PF_FROZEN;
45 wake_up_process(p);
46 return 1;
47 }
48 return 0;
49}
50
51/*
52 * freezing is complete, mark process as frozen
53 */
54static inline void frozen_process(struct task_struct *p)
55{
56 p->flags |= PF_FROZEN;
57 wmb();
58 clear_tsk_thread_flag(p, TIF_FREEZE);
59}
60
61extern void refrigerator(void);
62extern int freeze_processes(void);
63extern void thaw_processes(void);
64
65static inline int try_to_freeze(void)
66{
67 if (freezing(current)) {
68 refrigerator();
69 return 1;
70 } else
71 return 0;
72}
73
74extern void thaw_some_processes(int all);
75
76#else
77static inline int frozen(struct task_struct *p) { return 0; }
78static inline int freezing(struct task_struct *p) { return 0; }
79static inline void freeze(struct task_struct *p) { BUG(); }
80static inline int thaw_process(struct task_struct *p) { return 1; }
81static inline void frozen_process(struct task_struct *p) { BUG(); }
82
83static inline void refrigerator(void) {}
84static inline int freeze_processes(void) { BUG(); return 0; }
85static inline void thaw_processes(void) {}
86
87static inline int try_to_freeze(void) { return 0; }
88
89
90#endif