File: pid.h

package info (click to toggle)
linux-kernel-headers 2.5.999-test7-bk-17
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 28,268 kB
  • ctags: 214,024
  • sloc: ansic: 324,929; cpp: 783; makefile: 79; asm: 61; sh: 61
file content (64 lines) | stat: -rw-r--r-- 1,524 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#ifndef _LINUX_PID_H
#define _LINUX_PID_H

enum pid_type
{
	PIDTYPE_PID,
	PIDTYPE_TGID,
	PIDTYPE_PGID,
	PIDTYPE_SID,
	PIDTYPE_MAX
};

struct pid
{
	int nr;
	atomic_t count;
	struct task_struct *task;
	struct list_head task_list;
	struct list_head hash_chain;
};

struct pid_link
{
	struct list_head pid_chain;
	struct pid *pidptr;
	struct pid pid;
};

#define pid_task(elem, type) \
	list_entry(elem, struct task_struct, pids[type].pid_chain)

/*
 * attach_pid() and link_pid() must be called with the tasklist_lock
 * write-held.
 */
extern int FASTCALL(attach_pid(struct task_struct *task, enum pid_type type, int nr));

extern void FASTCALL(link_pid(struct task_struct *task, struct pid_link *link, struct pid *pid));

/*
 * detach_pid() must be called with the tasklist_lock write-held.
 */
extern void FASTCALL(detach_pid(struct task_struct *task, enum pid_type));

/*
 * look up a PID in the hash table. Must be called with the tasklist_lock
 * held.
 */
extern struct pid *FASTCALL(find_pid(enum pid_type, int));

extern int alloc_pidmap(void);
extern void FASTCALL(free_pidmap(int));
extern void switch_exec_pids(struct task_struct *leader, struct task_struct *thread);

#define for_each_task_pid(who, type, task, elem, pid)		\
	if ((pid = find_pid(type, who)))			\
	        for (elem = pid->task_list.next,			\
			prefetch(elem->next),				\
			task = pid_task(elem, type);			\
			elem != &pid->task_list;			\
			elem = elem->next, prefetch(elem->next), 	\
			task = pid_task(elem, type))

#endif /* _LINUX_PID_H */