freezer.h 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. /* Freezer declarations */
  2. #include <linux/sched.h>
  3. #ifdef CONFIG_PM
  4. /*
  5. * Check if a process has been frozen
  6. */
  7. static inline int frozen(struct task_struct *p)
  8. {
  9. return p->flags & PF_FROZEN;
  10. }
  11. /*
  12. * Check if there is a request to freeze a process
  13. */
  14. static inline int freezing(struct task_struct *p)
  15. {
  16. return p->flags & PF_FREEZE;
  17. }
  18. /*
  19. * Request that a process be frozen
  20. * FIXME: SMP problem. We may not modify other process' flags!
  21. */
  22. static inline void freeze(struct task_struct *p)
  23. {
  24. p->flags |= PF_FREEZE;
  25. }
  26. /*
  27. * Sometimes we may need to cancel the previous 'freeze' request
  28. */
  29. static inline void do_not_freeze(struct task_struct *p)
  30. {
  31. p->flags &= ~PF_FREEZE;
  32. }
  33. /*
  34. * Wake up a frozen process
  35. */
  36. static inline int thaw_process(struct task_struct *p)
  37. {
  38. if (frozen(p)) {
  39. p->flags &= ~PF_FROZEN;
  40. wake_up_process(p);
  41. return 1;
  42. }
  43. return 0;
  44. }
  45. /*
  46. * freezing is complete, mark process as frozen
  47. */
  48. static inline void frozen_process(struct task_struct *p)
  49. {
  50. p->flags = (p->flags & ~PF_FREEZE) | PF_FROZEN;
  51. }
  52. extern void refrigerator(void);
  53. extern int freeze_processes(void);
  54. extern void thaw_processes(void);
  55. static inline int try_to_freeze(void)
  56. {
  57. if (freezing(current)) {
  58. refrigerator();
  59. return 1;
  60. } else
  61. return 0;
  62. }
  63. extern void thaw_some_processes(int all);
  64. #else
  65. static inline int frozen(struct task_struct *p) { return 0; }
  66. static inline int freezing(struct task_struct *p) { return 0; }
  67. static inline void freeze(struct task_struct *p) { BUG(); }
  68. static inline int thaw_process(struct task_struct *p) { return 1; }
  69. static inline void frozen_process(struct task_struct *p) { BUG(); }
  70. static inline void refrigerator(void) {}
  71. static inline int freeze_processes(void) { BUG(); return 0; }
  72. static inline void thaw_processes(void) {}
  73. static inline int try_to_freeze(void) { return 0; }
  74. #endif