diff options
Diffstat (limited to 'include/linux/sched.h')
-rw-r--r-- | include/linux/sched.h | 73 |
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 |
1254 | extern void refrigerator(unsigned long); | 1249 | /* |
1250 | * Check if a process has been frozen | ||
1251 | */ | ||
1252 | static 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 | */ | ||
1260 | static 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 | */ | ||
1269 | static inline void freeze(struct task_struct *p) | ||
1270 | { | ||
1271 | p->flags |= PF_FREEZE; | ||
1272 | } | ||
1273 | |||
1274 | /* | ||
1275 | * Wake up a frozen process | ||
1276 | */ | ||
1277 | static 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 | */ | ||
1290 | static inline void frozen_process(struct task_struct *p) | ||
1291 | { | ||
1292 | p->flags = (p->flags & ~PF_FREEZE) | PF_FROZEN; | ||
1293 | } | ||
1294 | |||
1295 | extern void refrigerator(void); | ||
1255 | extern int freeze_processes(void); | 1296 | extern int freeze_processes(void); |
1256 | extern void thaw_processes(void); | 1297 | extern void thaw_processes(void); |
1257 | 1298 | ||
1258 | static inline int try_to_freeze(unsigned long refrigerator_flags) | 1299 | static 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 |
1267 | static inline void refrigerator(unsigned long flag) {} | 1308 | static inline int frozen(struct task_struct *p) { return 0; } |
1309 | static inline int freezing(struct task_struct *p) { return 0; } | ||
1310 | static inline void freeze(struct task_struct *p) { BUG(); } | ||
1311 | static inline int thaw_process(struct task_struct *p) { return 1; } | ||
1312 | static inline void frozen_process(struct task_struct *p) { BUG(); } | ||
1313 | |||
1314 | static inline void refrigerator(void) {} | ||
1268 | static inline int freeze_processes(void) { BUG(); return 0; } | 1315 | static inline int freeze_processes(void) { BUG(); return 0; } |
1269 | static inline void thaw_processes(void) {} | 1316 | static inline void thaw_processes(void) {} |
1270 | 1317 | ||
1271 | static inline int try_to_freeze(unsigned long refrigerator_flags) | 1318 | static 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 | ||