aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/freezer.h
diff options
context:
space:
mode:
authorNigel Cunningham <ncunningham@linuxmail.org>2006-12-06 23:34:23 -0500
committerLinus Torvalds <torvalds@woody.osdl.org>2006-12-07 11:39:27 -0500
commit7dfb71030f7636a0d65200158113c37764552f93 (patch)
tree276b812903d377b16d8828e888552fd256f48aab /include/linux/freezer.h
parent8a05aac2631aa0e6494d9dc990f8c68ed8b8fde7 (diff)
[PATCH] Add include/linux/freezer.h and move definitions from sched.h
Move process freezing functions from include/linux/sched.h to freezer.h, so that modifications to the freezer or the kernel configuration don't require recompiling just about everything. [akpm@osdl.org: fix ueagle driver] Signed-off-by: Nigel Cunningham <nigel@suspend2.net> Cc: "Rafael J. Wysocki" <rjw@sisk.pl> Cc: Pavel Machek <pavel@ucw.cz> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'include/linux/freezer.h')
-rw-r--r--include/linux/freezer.h84
1 files changed, 84 insertions, 0 deletions
diff --git a/include/linux/freezer.h b/include/linux/freezer.h
new file mode 100644
index 000000000000..266373f74445
--- /dev/null
+++ b/include/linux/freezer.h
@@ -0,0 +1,84 @@
1/* Freezer declarations */
2
3#ifdef CONFIG_PM
4/*
5 * Check if a process has been frozen
6 */
7static inline int frozen(struct task_struct *p)
8{
9 return p->flags & PF_FROZEN;
10}
11
12/*
13 * Check if there is a request to freeze a process
14 */
15static inline int freezing(struct task_struct *p)
16{
17 return p->flags & PF_FREEZE;
18}
19
20/*
21 * Request that a process be frozen
22 * FIXME: SMP problem. We may not modify other process' flags!
23 */
24static inline void freeze(struct task_struct *p)
25{
26 p->flags |= PF_FREEZE;
27}
28
29/*
30 * Sometimes we may need to cancel the previous 'freeze' request
31 */
32static inline void do_not_freeze(struct task_struct *p)
33{
34 p->flags &= ~PF_FREEZE;
35}
36
37/*
38 * Wake up a frozen process
39 */
40static inline int thaw_process(struct task_struct *p)
41{
42 if (frozen(p)) {
43 p->flags &= ~PF_FROZEN;
44 wake_up_process(p);
45 return 1;
46 }
47 return 0;
48}
49
50/*
51 * freezing is complete, mark process as frozen
52 */
53static inline void frozen_process(struct task_struct *p)
54{
55 p->flags = (p->flags & ~PF_FREEZE) | PF_FROZEN;
56}
57
58extern void refrigerator(void);
59extern int freeze_processes(void);
60extern void thaw_processes(void);
61
62static inline int try_to_freeze(void)
63{
64 if (freezing(current)) {
65 refrigerator();
66 return 1;
67 } else
68 return 0;
69}
70#else
71static inline int frozen(struct task_struct *p) { return 0; }
72static inline int freezing(struct task_struct *p) { return 0; }
73static inline void freeze(struct task_struct *p) { BUG(); }
74static inline int thaw_process(struct task_struct *p) { return 1; }
75static inline void frozen_process(struct task_struct *p) { BUG(); }
76
77static inline void refrigerator(void) {}
78static inline int freeze_processes(void) { BUG(); return 0; }
79static inline void thaw_processes(void) {}
80
81static inline int try_to_freeze(void) { return 0; }
82
83
84#endif