pid.h 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. #ifndef _LINUX_PID_H
  2. #define _LINUX_PID_H
  3. enum pid_type
  4. {
  5. PIDTYPE_PID,
  6. PIDTYPE_TGID,
  7. PIDTYPE_PGID,
  8. PIDTYPE_SID,
  9. PIDTYPE_MAX
  10. };
  11. struct pid
  12. {
  13. /* Try to keep pid_chain in the same cacheline as nr for find_pid */
  14. int nr;
  15. struct hlist_node pid_chain;
  16. /* list of pids with the same nr, only one of them is in the hash */
  17. struct list_head pid_list;
  18. };
  19. #define pid_task(elem, type) \
  20. list_entry(elem, struct task_struct, pids[type].pid_list)
  21. /*
  22. * attach_pid() and detach_pid() must be called with the tasklist_lock
  23. * write-held.
  24. */
  25. extern int FASTCALL(attach_pid(struct task_struct *task, enum pid_type type, int nr));
  26. extern void FASTCALL(detach_pid(struct task_struct *task, enum pid_type));
  27. /*
  28. * look up a PID in the hash table. Must be called with the tasklist_lock
  29. * held.
  30. */
  31. extern struct pid *FASTCALL(find_pid(enum pid_type, int));
  32. extern int alloc_pidmap(void);
  33. extern void FASTCALL(free_pidmap(int));
  34. extern void switch_exec_pids(struct task_struct *leader, struct task_struct *thread);
  35. #define do_each_task_pid(who, type, task) \
  36. if ((task = find_task_by_pid_type(type, who))) { \
  37. prefetch((task)->pids[type].pid_list.next); \
  38. do {
  39. #define while_each_task_pid(who, type, task) \
  40. } while (task = pid_task((task)->pids[type].pid_list.next,\
  41. type), \
  42. prefetch((task)->pids[type].pid_list.next), \
  43. hlist_unhashed(&(task)->pids[type].pid_chain)); \
  44. } \
  45. #endif /* _LINUX_PID_H */