freezer.h 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. /* Freezer declarations */
  2. #ifdef CONFIG_PM
  3. /*
  4. * Check if a process has been frozen
  5. */
  6. static inline int frozen(struct task_struct *p)
  7. {
  8. return p->flags & PF_FROZEN;
  9. }
  10. /*
  11. * Check if there is a request to freeze a process
  12. */
  13. static inline int freezing(struct task_struct *p)
  14. {
  15. return p->flags & PF_FREEZE;
  16. }
  17. /*
  18. * Request that a process be frozen
  19. * FIXME: SMP problem. We may not modify other process' flags!
  20. */
  21. static inline void freeze(struct task_struct *p)
  22. {
  23. p->flags |= PF_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. p->flags &= ~PF_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 = (p->flags & ~PF_FREEZE) | PF_FROZEN;
  50. }
  51. extern void refrigerator(void);
  52. extern int freeze_processes(void);
  53. extern void thaw_processes(void);
  54. static inline int try_to_freeze(void)
  55. {
  56. if (freezing(current)) {
  57. refrigerator();
  58. return 1;
  59. } else
  60. return 0;
  61. }
  62. extern void thaw_some_processes(int all);
  63. #else
  64. static inline int frozen(struct task_struct *p) { return 0; }
  65. static inline int freezing(struct task_struct *p) { return 0; }
  66. static inline void freeze(struct task_struct *p) { BUG(); }
  67. static inline int thaw_process(struct task_struct *p) { return 1; }
  68. static inline void frozen_process(struct task_struct *p) { BUG(); }
  69. static inline void refrigerator(void) {}
  70. static inline int freeze_processes(void) { BUG(); return 0; }
  71. static inline void thaw_processes(void) {}
  72. static inline int try_to_freeze(void) { return 0; }
  73. #endif