kernel_threads.txt 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. KERNEL THREADS
  2. Freezer
  3. Upon entering a suspended state the system will freeze all
  4. tasks. This is done by delivering pseudosignals. This affects
  5. kernel threads, too. To successfully freeze a kernel thread
  6. the thread has to check for the pseudosignal and enter the
  7. refrigerator. Code to do this looks like this:
  8. do {
  9. hub_events();
  10. wait_event_interruptible(khubd_wait, !list_empty(&hub_event_list));
  11. try_to_freeze();
  12. } while (!signal_pending(current));
  13. from drivers/usb/core/hub.c::hub_thread()
  14. The Unfreezable
  15. Some kernel threads however, must not be frozen. The kernel must
  16. be able to finish pending IO operations and later on be able to
  17. write the memory image to disk. Kernel threads needed to do IO
  18. must stay awake. Such threads must mark themselves unfreezable
  19. like this:
  20. /*
  21. * This thread doesn't need any user-level access,
  22. * so get rid of all our resources.
  23. */
  24. daemonize("usb-storage");
  25. current->flags |= PF_NOFREEZE;
  26. from drivers/usb/storage/usb.c::usb_stor_control_thread()
  27. Such drivers are themselves responsible for staying quiet during
  28. the actual snapshotting.