lkml.org 
[lkml]   [2005]   [Nov]   [14]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
Subject[RFC] [PATCH 13/13] Define new task_pid api
Replace-Subject: Define new task_pid api
From: Serge Hallyn <serue@us.ibm.com>

Actually define the task_pid() and task_tgid() functions. Also
replace pid with __pid so as to make sure any missed accessors are
caught.

The resulting object code seems to be identical in most cases, and is
actually shorter in cases where current->pid is used twice in a row,
as it does not dereference task-> twice.

Signed-off-by: Dave Hansen <haveblue@us.ibm.com>
Signed-off-by: Serge Hallyn <serue@us.ibm.com>
---
include/linux/sched.h | 16 +++++++++++++---
1 files changed, 13 insertions(+), 3 deletions(-)
Index: linux-2.6.15-rc1/include/linux/sched.h
===================================================================
--- linux-2.6.15-rc1.orig/include/linux/sched.h
+++ linux-2.6.15-rc1/include/linux/sched.h
@@ -733,8 +733,8 @@ struct task_struct {
/* ??? */
unsigned long personality;
unsigned did_exec:1;
- pid_t pid;
- pid_t tgid;
+ pid_t __pid;
+ pid_t __tgid;
/*
* pointers to (original) parent process, youngest child, younger sibling,
* older sibling, respectively. (p->father can be replaced with
@@ -878,6 +878,16 @@ static inline int pid_alive(struct task_
return p->pids[PIDTYPE_PID].nr != 0;
}

+static inline pid_t task_pid(const struct task_struct *p)
+{
+ return p->__pid;
+}
+
+static inline pid_t task_tgid(const struct task_struct *p)
+{
+ return p->__tgid;
+}
+
extern void free_task(struct task_struct *tsk);
extern void __put_task_struct(struct task_struct *tsk);
#define get_task_struct(tsk) do { atomic_inc(&(tsk)->usage); } while(0)
@@ -1202,7 +1212,7 @@ extern void wait_task_inactive(task_t *

extern task_t * FASTCALL(next_thread(const task_t *p));

-#define thread_group_leader(p) (p->pid == p->tgid)
+#define thread_group_leader(p) (task_pid(p) == task_tgid(p))

static inline int thread_group_empty(task_t *p)
{
--

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-11-14 22:37    [W:0.353 / U:0.096 seconds]
©2003-2014 Jasper Spaans. Advertise on this site