Rev 422 | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
422 | giacomo | 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 | }; |
||
12 | |||
13 | struct pid |
||
14 | { |
||
15 | int nr; |
||
16 | atomic_t count; |
||
17 | struct task_struct *task; |
||
18 | struct list_head task_list; |
||
19 | struct list_head hash_chain; |
||
20 | }; |
||
21 | |||
22 | struct pid_link |
||
23 | { |
||
24 | struct list_head pid_chain; |
||
25 | struct pid *pidptr; |
||
26 | struct pid pid; |
||
27 | }; |
||
28 | |||
29 | #define pid_task(elem, type) \ |
||
30 | list_entry(elem, struct task_struct, pids[type].pid_chain) |
||
31 | |||
32 | /* |
||
33 | * attach_pid() and link_pid() must be called with the tasklist_lock |
||
34 | * write-held. |
||
35 | */ |
||
36 | extern int FASTCALL(attach_pid(struct task_struct *task, enum pid_type type, int nr)); |
||
37 | |||
38 | extern void FASTCALL(link_pid(struct task_struct *task, struct pid_link *link, struct pid *pid)); |
||
39 | |||
40 | /* |
||
41 | * detach_pid() must be called with the tasklist_lock write-held. |
||
42 | */ |
||
43 | extern void FASTCALL(detach_pid(struct task_struct *task, enum pid_type)); |
||
44 | |||
45 | /* |
||
46 | * look up a PID in the hash table. Must be called with the tasklist_lock |
||
47 | * held. |
||
48 | */ |
||
49 | extern struct pid *FASTCALL(find_pid(enum pid_type, int)); |
||
50 | |||
51 | extern int alloc_pidmap(void); |
||
52 | extern void FASTCALL(free_pidmap(int)); |
||
53 | extern void switch_exec_pids(struct task_struct *leader, struct task_struct *thread); |
||
54 | |||
55 | #define for_each_task_pid(who, type, task, elem, pid) \ |
||
56 | if ((pid = find_pid(type, who))) \ |
||
57 | for (elem = pid->task_list.next, \ |
||
58 | prefetch(elem->next), \ |
||
59 | task = pid_task(elem, type); \ |
||
60 | elem != &pid->task_list; \ |
||
61 | elem = elem->next, prefetch(elem->next), \ |
||
62 | task = pid_task(elem, type)) |
||
63 | |||
64 | #endif /* _LINUX_PID_H */ |