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