task.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. #ifndef _LINUX_SCHED_TASK_H
  2. #define _LINUX_SCHED_TASK_H
  3. /*
  4. * Interface between the scheduler and various task lifetime (fork()/exit())
  5. * functionality:
  6. */
  7. #include <linux/sched.h>
  8. /*
  9. * This serializes "schedule()" and also protects
  10. * the run-queue from deletions/modifications (but
  11. * _adding_ to the beginning of the run-queue has
  12. * a separate lock).
  13. */
  14. extern rwlock_t tasklist_lock;
  15. extern spinlock_t mmlist_lock;
  16. #ifdef CONFIG_PROVE_RCU
  17. extern int lockdep_tasklist_lock_is_held(void);
  18. #endif /* #ifdef CONFIG_PROVE_RCU */
  19. extern asmlinkage void schedule_tail(struct task_struct *prev);
  20. extern void init_idle(struct task_struct *idle, int cpu);
  21. extern void init_idle_bootup_task(struct task_struct *idle);
  22. static inline void rcu_copy_process(struct task_struct *p)
  23. {
  24. #ifdef CONFIG_PREEMPT_RCU
  25. p->rcu_read_lock_nesting = 0;
  26. p->rcu_read_unlock_special.s = 0;
  27. p->rcu_blocked_node = NULL;
  28. INIT_LIST_HEAD(&p->rcu_node_entry);
  29. #endif /* #ifdef CONFIG_PREEMPT_RCU */
  30. #ifdef CONFIG_TASKS_RCU
  31. p->rcu_tasks_holdout = false;
  32. INIT_LIST_HEAD(&p->rcu_tasks_holdout_list);
  33. p->rcu_tasks_idle_cpu = -1;
  34. #endif /* #ifdef CONFIG_TASKS_RCU */
  35. }
  36. extern int sched_fork(unsigned long clone_flags, struct task_struct *p);
  37. extern void sched_dead(struct task_struct *p);
  38. void __noreturn do_task_dead(void);
  39. extern void proc_caches_init(void);
  40. extern void release_task(struct task_struct * p);
  41. #ifdef CONFIG_HAVE_COPY_THREAD_TLS
  42. extern int copy_thread_tls(unsigned long, unsigned long, unsigned long,
  43. struct task_struct *, unsigned long);
  44. #else
  45. extern int copy_thread(unsigned long, unsigned long, unsigned long,
  46. struct task_struct *);
  47. /* Architectures that haven't opted into copy_thread_tls get the tls argument
  48. * via pt_regs, so ignore the tls argument passed via C. */
  49. static inline int copy_thread_tls(
  50. unsigned long clone_flags, unsigned long sp, unsigned long arg,
  51. struct task_struct *p, unsigned long tls)
  52. {
  53. return copy_thread(clone_flags, sp, arg, p);
  54. }
  55. #endif
  56. extern void flush_thread(void);
  57. #ifdef CONFIG_HAVE_EXIT_THREAD
  58. extern void exit_thread(struct task_struct *tsk);
  59. #else
  60. static inline void exit_thread(struct task_struct *tsk)
  61. {
  62. }
  63. #endif
  64. extern void do_group_exit(int);
  65. extern long _do_fork(unsigned long, unsigned long, unsigned long, int __user *, int __user *, unsigned long);
  66. extern long do_fork(unsigned long, unsigned long, unsigned long, int __user *, int __user *);
  67. struct task_struct *fork_idle(int);
  68. extern pid_t kernel_thread(int (*fn)(void *), void *arg, unsigned long flags);
  69. #ifdef CONFIG_ARCH_WANTS_DYNAMIC_TASK_STRUCT
  70. extern int arch_task_struct_size __read_mostly;
  71. #else
  72. # define arch_task_struct_size (sizeof(struct task_struct))
  73. #endif
  74. #ifdef CONFIG_VMAP_STACK
  75. static inline struct vm_struct *task_stack_vm_area(const struct task_struct *t)
  76. {
  77. return t->stack_vm_area;
  78. }
  79. #else
  80. static inline struct vm_struct *task_stack_vm_area(const struct task_struct *t)
  81. {
  82. return NULL;
  83. }
  84. #endif
  85. #endif /* _LINUX_SCHED_TASK_H */