freezer.h 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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 test_tsk_thread_flag(p, TIF_FREEZE);
  17. }
  18. /*
  19. * Request that a process be frozen
  20. */
  21. static inline void freeze(struct task_struct *p)
  22. {
  23. set_tsk_thread_flag(p, TIF_FREEZE);
  24. }
  25. /*
  26. * Sometimes we may need to cancel the previous 'freeze' request
  27. */
  28. static inline void do_not_freeze(struct task_struct *p)
  29. {
  30. clear_tsk_thread_flag(p, TIF_FREEZE);
  31. }
  32. /*
  33. * Wake up a frozen process
  34. */
  35. static inline int thaw_process(struct task_struct *p)
  36. {
  37. if (frozen(p)) {
  38. p->flags &= ~PF_FROZEN;
  39. wake_up_process(p);
  40. return 1;
  41. }
  42. return 0;
  43. }
  44. /*
  45. * freezing is complete, mark process as frozen
  46. */
  47. static inline void frozen_process(struct task_struct *p)
  48. {
  49. p->flags |= PF_FROZEN;
  50. wmb();
  51. clear_tsk_thread_flag(p, TIF_FREEZE);
  52. }
  53. extern void refrigerator(void);
  54. extern int freeze_processes(void);
  55. extern void thaw_processes(void);
  56. static inline int try_to_freeze(void)
  57. {
  58. if (freezing(current)) {
  59. refrigerator();
  60. return 1;
  61. } else
  62. return 0;
  63. }
  64. extern void thaw_some_processes(int all);
  65. #else
  66. static inline int frozen(struct task_struct *p) { return 0; }
  67. static inline int freezing(struct task_struct *p) { return 0; }
  68. static inline void freeze(struct task_struct *p) { BUG(); }
  69. static inline int thaw_process(struct task_struct *p) { return 1; }
  70. static inline void frozen_process(struct task_struct *p) { BUG(); }
  71. static inline void refrigerator(void) {}
  72. static inline int freeze_processes(void) { BUG(); return 0; }
  73. static inline void thaw_processes(void) {}
  74. static inline int try_to_freeze(void) { return 0; }
  75. #endif