Commit 4b035e53 authored by Linus Torvalds's avatar Linus Torvalds Committed by Kai Germaschewski

Cleanup: use list macros for task list

parent 3154d91d
...@@ -828,7 +828,7 @@ static void __init do_boot_cpu (int apicid) ...@@ -828,7 +828,7 @@ static void __init do_boot_cpu (int apicid)
* We remove it from the pidhash and the runqueue * We remove it from the pidhash and the runqueue
* once we got the process: * once we got the process:
*/ */
idle = init_task.prev_task; idle = prev_task(&init_task);
if (!idle) if (!idle)
panic("No idle process for CPU %d", cpu); panic("No idle process for CPU %d", cpu);
......
...@@ -53,8 +53,7 @@ ...@@ -53,8 +53,7 @@
active_mm: &init_mm, \ active_mm: &init_mm, \
run_list: LIST_HEAD_INIT(tsk.run_list), \ run_list: LIST_HEAD_INIT(tsk.run_list), \
time_slice: HZ, \ time_slice: HZ, \
next_task: &tsk, \ tasks: LIST_HEAD_INIT(tsk.tasks), \
prev_task: &tsk, \
real_parent: &tsk, \ real_parent: &tsk, \
parent: &tsk, \ parent: &tsk, \
children: LIST_HEAD_INIT(tsk.children), \ children: LIST_HEAD_INIT(tsk.children), \
......
...@@ -250,7 +250,7 @@ struct task_struct { ...@@ -250,7 +250,7 @@ struct task_struct {
unsigned long cpus_allowed; unsigned long cpus_allowed;
unsigned int time_slice; unsigned int time_slice;
struct task_struct *next_task, *prev_task; struct list_head tasks;
struct mm_struct *mm, *active_mm; struct mm_struct *mm, *active_mm;
struct list_head local_pages; struct list_head local_pages;
...@@ -718,18 +718,17 @@ do { \ ...@@ -718,18 +718,17 @@ do { \
__ret; \ __ret; \
}) })
#define remove_parent(p) list_del_init(&(p)->sibling)
#define add_parent(p, parent) list_add_tail(&(p)->sibling,&(parent)->children)
#define REMOVE_LINKS(p) do { \ #define REMOVE_LINKS(p) do { \
(p)->next_task->prev_task = (p)->prev_task; \ list_del_init(&(p)->tasks); \
(p)->prev_task->next_task = (p)->next_task; \ remove_parent(p); \
list_del_init(&(p)->sibling); \
} while (0) } while (0)
#define SET_LINKS(p) do { \ #define SET_LINKS(p) do { \
(p)->next_task = &init_task; \ list_add_tail(&(p)->tasks,&init_task.tasks); \
(p)->prev_task = init_task.prev_task; \ add_parent(p, (p)->parent); \
init_task.prev_task->next_task = (p); \
init_task.prev_task = (p); \
list_add_tail(&(p)->sibling,&(p)->parent->children); \
} while (0) } while (0)
static inline struct task_struct *eldest_child(struct task_struct *p) static inline struct task_struct *eldest_child(struct task_struct *p)
...@@ -756,8 +755,11 @@ static inline struct task_struct *younger_sibling(struct task_struct *p) ...@@ -756,8 +755,11 @@ static inline struct task_struct *younger_sibling(struct task_struct *p)
return list_entry(p->sibling.next,struct task_struct,sibling); return list_entry(p->sibling.next,struct task_struct,sibling);
} }
#define next_task(p) list_entry((p)->tasks.next, struct task_struct, tasks)
#define prev_task(p) list_entry((p)->tasks.prev, struct task_struct, tasks)
#define for_each_task(p) \ #define for_each_task(p) \
for (p = &init_task ; (p = p->next_task) != &init_task ; ) for (p = &init_task ; (p = next_task(p)) != &init_task ; )
#define for_each_thread(task) \ #define for_each_thread(task) \
for (task = next_thread(current) ; task != current ; task = next_thread(task)) for (task = next_thread(current) ; task != current ; task = next_thread(task))
......
...@@ -612,9 +612,9 @@ asmlinkage long sys_wait4(pid_t pid,unsigned int * stat_addr, int options, struc ...@@ -612,9 +612,9 @@ asmlinkage long sys_wait4(pid_t pid,unsigned int * stat_addr, int options, struc
retval = p->pid; retval = p->pid;
if (p->real_parent != p->parent) { if (p->real_parent != p->parent) {
write_lock_irq(&tasklist_lock); write_lock_irq(&tasklist_lock);
REMOVE_LINKS(p); remove_parent(p);
p->parent = p->real_parent; p->parent = p->real_parent;
SET_LINKS(p); add_parent(p, p->parent);
do_notify_parent(p, SIGCHLD); do_notify_parent(p, SIGCHLD);
write_unlock_irq(&tasklist_lock); write_unlock_irq(&tasklist_lock);
} else } else
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment