kthread.h 1.1 KB

123456789101112131415161718192021222324252627282930313233343536
  1. #ifndef _LINUX_KTHREAD_H
  2. #define _LINUX_KTHREAD_H
  3. /* Simple interface for creating and stopping kernel threads without mess. */
  4. #include <linux/err.h>
  5. #include <linux/sched.h>
  6. struct task_struct *kthread_create(int (*threadfn)(void *data),
  7. void *data,
  8. const char namefmt[], ...);
  9. /**
  10. * kthread_run - create and wake a thread.
  11. * @threadfn: the function to run until signal_pending(current).
  12. * @data: data ptr for @threadfn.
  13. * @namefmt: printf-style name for the thread.
  14. *
  15. * Description: Convenient wrapper for kthread_create() followed by
  16. * wake_up_process(). Returns the kthread or ERR_PTR(-ENOMEM).
  17. */
  18. #define kthread_run(threadfn, data, namefmt, ...) \
  19. ({ \
  20. struct task_struct *__k \
  21. = kthread_create(threadfn, data, namefmt, ## __VA_ARGS__); \
  22. if (!IS_ERR(__k)) \
  23. wake_up_process(__k); \
  24. __k; \
  25. })
  26. void kthread_bind(struct task_struct *k, unsigned int cpu);
  27. int kthread_stop(struct task_struct *k);
  28. int kthread_should_stop(void);
  29. int kthreadd(void *unused);
  30. extern struct task_struct *kthreadd_task;
  31. #endif /* _LINUX_KTHREAD_H */