aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/sched.h
diff options
context:
space:
mode:
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 2c69682b0444..e7fd09b0557f 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -1245,33 +1245,78 @@ extern void normalize_rt_tasks(void);
1245 1245
1246#endif 1246#endif
1247 1247
1248/* try_to_freeze
1249 *
1250 * Checks whether we need to enter the refrigerator
1251 * and returns 1 if we did so.
1252 */
1253#ifdef CONFIG_PM 1248#ifdef CONFIG_PM
1254extern void refrigerator(unsigned long); 1249/*
1250 * Check if a process has been frozen
1251 */
1252static inline int frozen(struct task_struct *p)
1253{
1254 return p->flags & PF_FROZEN;
1255}
1256
1257/*
1258 * Check if there is a request to freeze a process
1259 */
1260static inline int freezing(struct task_struct *p)
1261{
1262 return p->flags & PF_FREEZE;
1263}
1264
1265/*
1266 * Request that a process be frozen
1267 * FIXME: SMP problem. We may not modify other process' flags!
1268 */
1269static inline void freeze(struct task_struct *p)
1270{
1271 p->flags |= PF_FREEZE;
1272}
1273
1274/*
1275 * Wake up a frozen process
1276 */
1277static inline int thaw_process(struct task_struct *p)
1278{
1279 if (frozen(p)) {
1280 p->flags &= ~PF_FROZEN;
1281 wake_up_process(p);
1282 return 1;
1283 }
1284 return 0;
1285}
1286
1287/*
1288 * freezing is complete, mark process as frozen
1289 */
1290static inline void frozen_process(struct task_struct *p)
1291{
1292 p->flags = (p->flags & ~PF_FREEZE) | PF_FROZEN;
1293}
1294
1295extern void refrigerator(void);
1255extern int freeze_processes(void); 1296extern int freeze_processes(void);
1256extern void thaw_processes(void); 1297extern void thaw_processes(void);
1257 1298
1258static inline int try_to_freeze(unsigned long refrigerator_flags) 1299static inline int try_to_freeze(void)
1259{ 1300{
1260 if (unlikely(current->flags & PF_FREEZE)) { 1301 if (freezing(current)) {
1261 refrigerator(refrigerator_flags); 1302 refrigerator();
1262 return 1; 1303 return 1;
1263 } else 1304 } else
1264 return 0; 1305 return 0;
1265} 1306}
1266#else 1307#else
1267static inline void refrigerator(unsigned long flag) {} 1308static inline int frozen(struct task_struct *p) { return 0; }
1309static inline int freezing(struct task_struct *p) { return 0; }
1310static inline void freeze(struct task_struct *p) { BUG(); }
1311static inline int thaw_process(struct task_struct *p) { return 1; }
1312static inline void frozen_process(struct task_struct *p) { BUG(); }
1313
1314static inline void refrigerator(void) {}
1268static inline int freeze_processes(void) { BUG(); return 0; } 1315static inline int freeze_processes(void) { BUG(); return 0; }
1269static inline void thaw_processes(void) {} 1316static inline void thaw_processes(void) {}
1270 1317
1271static inline int try_to_freeze(unsigned long refrigerator_flags) 1318static inline int try_to_freeze(void) { return 0; }
1272{ 1319
1273 return 0;
1274}
1275#endif /* CONFIG_PM */ 1320#endif /* CONFIG_PM */
1276#endif /* __KERNEL__ */ 1321#endif /* __KERNEL__ */
1277 1322