aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/sched.h
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@ppc970.osdl.org>2005-06-25 20:16:53 -0400
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-06-25 20:16:53 -0400
commit2031d0f586839bc68f35bcf8580b18947f8491d4 (patch)
treee317615b4cb62350edeea0afe0a4fc94152cee29 /include/linux/sched.h
parent98e7f29418a4931f97e6b78d1ef3a47103fe6cd5 (diff)
parent3e1d1d28d99dabe63c64f7f40f1ca1d646de1f73 (diff)
Merge Christoph's freeze cleanup patch
Diffstat (limited to 'include/linux/sched.h')
-rw-r--r--include/linux/sched.h73
1 files changed, 59 insertions, 14 deletions
diff --git a/include/linux/sched.h b/include/linux/sched.h
index 98c109e4f43d..9530b1903160 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -1265,33 +1265,78 @@ extern void normalize_rt_tasks(void);
1265 1265
1266#endif 1266#endif
1267 1267
1268/* try_to_freeze
1269 *
1270 * Checks whether we need to enter the refrigerator
1271 * and returns 1 if we did so.
1272 */
1273#ifdef CONFIG_PM 1268#ifdef CONFIG_PM
1274extern void refrigerator(unsigned long); 1269/*
1270 * Check if a process has been frozen
1271 */
1272static inline int frozen(struct task_struct *p)
1273{
1274 return p->flags & PF_FROZEN;
1275}
1276
1277/*
1278 * Check if there is a request to freeze a process
1279 */
1280static inline int freezing(struct task_struct *p)
1281{
1282 return p->flags & PF_FREEZE;
1283}
1284
1285/*
1286 * Request that a process be frozen
1287 * FIXME: SMP problem. We may not modify other process' flags!
1288 */
1289static inline void freeze(struct task_struct *p)
1290{
1291 p->flags |= PF_FREEZE;
1292}
1293
1294/*
1295 * Wake up a frozen process
1296 */
1297static inline int thaw_process(struct task_struct *p)
1298{
1299 if (frozen(p)) {
1300 p->flags &= ~PF_FROZEN;
1301 wake_up_process(p);
1302 return 1;
1303 }
1304 return 0;
1305}
1306
1307/*
1308 * freezing is complete, mark process as frozen
1309 */
1310static inline void frozen_process(struct task_struct *p)
1311{
1312 p->flags = (p->flags & ~PF_FREEZE) | PF_FROZEN;
1313}
1314
1315extern void refrigerator(void);
1275extern int freeze_processes(void); 1316extern int freeze_processes(void);
1276extern void thaw_processes(void); 1317extern void thaw_processes(void);
1277 1318
1278static inline int try_to_freeze(unsigned long refrigerator_flags) 1319static inline int try_to_freeze(void)
1279{ 1320{
1280 if (unlikely(current->flags & PF_FREEZE)) { 1321 if (freezing(current)) {
1281 refrigerator(refrigerator_flags); 1322 refrigerator();
1282 return 1; 1323 return 1;
1283 } else 1324 } else
1284 return 0; 1325 return 0;
1285} 1326}
1286#else 1327#else
1287static inline void refrigerator(unsigned long flag) {} 1328static inline int frozen(struct task_struct *p) { return 0; }
1329static inline int freezing(struct task_struct *p) { return 0; }
1330static inline void freeze(struct task_struct *p) { BUG(); }
1331static inline int thaw_process(struct task_struct *p) { return 1; }
1332static inline void frozen_process(struct task_struct *p) { BUG(); }
1333
1334static inline void refrigerator(void) {}
1288static inline int freeze_processes(void) { BUG(); return 0; } 1335static inline int freeze_processes(void) { BUG(); return 0; }
1289static inline void thaw_processes(void) {} 1336static inline void thaw_processes(void) {}
1290 1337
1291static inline int try_to_freeze(unsigned long refrigerator_flags) 1338static inline int try_to_freeze(void) { return 0; }
1292{ 1339
1293 return 0;
1294}
1295#endif /* CONFIG_PM */ 1340#endif /* CONFIG_PM */
1296#endif /* __KERNEL__ */ 1341#endif /* __KERNEL__ */
1297 1342