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)
* We remove it from the pidhash and the runqueue
* once we got the process:
*/
idle = init_task.prev_task;
idle = prev_task(&init_task);
if (!idle)
panic("No idle process for CPU %d", cpu);
......
......@@ -53,8 +53,7 @@
active_mm: &init_mm, \
run_list: LIST_HEAD_INIT(tsk.run_list), \
time_slice: HZ, \
next_task: &tsk, \
prev_task: &tsk, \
tasks: LIST_HEAD_INIT(tsk.tasks), \
real_parent: &tsk, \
parent: &tsk, \
children: LIST_HEAD_INIT(tsk.children), \
......
......@@ -250,7 +250,7 @@ struct task_struct {
unsigned long cpus_allowed;
unsigned int time_slice;
struct task_struct *next_task, *prev_task;
struct list_head tasks;
struct mm_struct *mm, *active_mm;
struct list_head local_pages;
......@@ -718,18 +718,17 @@ do { \
__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 { \
(p)->next_task->prev_task = (p)->prev_task; \
(p)->prev_task->next_task = (p)->next_task; \
list_del_init(&(p)->sibling); \
list_del_init(&(p)->tasks); \
remove_parent(p); \
} while (0)
#define SET_LINKS(p) do { \
(p)->next_task = &init_task; \
(p)->prev_task = init_task.prev_task; \
init_task.prev_task->next_task = (p); \
init_task.prev_task = (p); \
list_add_tail(&(p)->sibling,&(p)->parent->children); \
list_add_tail(&(p)->tasks,&init_task.tasks); \
add_parent(p, (p)->parent); \
} while (0)
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)
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) \
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) \
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
retval = p->pid;
if (p->real_parent != p->parent) {
write_lock_irq(&tasklist_lock);
REMOVE_LINKS(p);
remove_parent(p);
p->parent = p->real_parent;
SET_LINKS(p);
add_parent(p, p->parent);
do_notify_parent(p, SIGCHLD);
write_unlock_irq(&tasklist_lock);
} 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