l4_exit() works with a reasonable sched_die_sync()

Next: Killing other tasks more cleanly, and waiting on children
This commit is contained in:
Bahadir Balban
2009-10-29 22:44:58 +02:00
parent 73a27f2269
commit a6c61e05b9
9 changed files with 121 additions and 16 deletions

View File

@@ -68,6 +68,7 @@ int capability_share(unsigned int share_flags)
cap_list_move(&curcont->cap_list,
&current->cap_list);
break;
#if 0
case CAP_SHARE_CHILD:
/*
* Move own capabilities to paged-children
@@ -97,6 +98,7 @@ int capability_share(unsigned int share_flags)
&current->cap_list);
break;
}
#endif
default:
return -EINVAL;
}

View File

@@ -200,7 +200,7 @@ void thread_destroy_current(void)
/* Indicate we want to become zombie on suspend */
current->flags |= TASK_EXITING;
sched_suspend_sync();
sched_die_sync();
}
/* Runs a thread for the first time */

View File

@@ -144,8 +144,8 @@ int init_pager(struct pager *pager,
page_align_up(pager->memsize),
MAP_USR_DEFAULT_FLAGS, TASK_PGD(task));
/* Move capability list from dummy to task's cap list */
cap_list_move(&task->cap_list, &current->cap_list);
/* Move capability list from dummy to task's space cap list */
cap_list_move(&task->space->cap_list, &current->cap_list);
/* Initialize task scheduler parameters */
sched_init_task(task, TASK_PRIO_PAGER);

View File

@@ -226,6 +226,70 @@ void sched_resume_async(struct ktcb *task)
RQ_ADD_FRONT);
}
#if 0
/* FIXME: Disables preemption for unbounded time !!! */
void tcb_delete_schedule(void)
{
/* We lock all possible locks to do with */
address_space_lock();
/*
* Lock ktcb mutex cache so that nobody can get me
* during this period
*/
mutex_lock(&kernel_resources.ktcb_cache.lock);
tcb_delete(current);
preempt_disable();
sched_rq_remove_task(current);
current->state = TASK_INACTIVE;
scheduler.prio_total -= current->priority;
BUG_ON(scheduler.prio_total < 0);
ktcb_list_unlock();
address_space_list_unlock();
preempt_enable();
schedule();
}
#endif
void sched_die_sync(void)
{
/* Remove from its list, callers get -ESRCH */
tcb_remove(current);
/*
* If there are any sleepers on any of the task's
* waitqueues, we need to wake those tasks up.
*/
wake_up_all(&current->wqh_send, 0);
wake_up_all(&current->wqh_recv, 0);
/*
* We're a self-paging thread. We're gonna
* delete ourself and disappear from the
* system as soon as we schedule
*/
preempt_disable();
/*
* TOO LONG!
*/
tcb_delete(current);
sched_rq_remove_task(current);
current->state = TASK_INACTIVE;
scheduler.prio_total -= current->priority;
BUG_ON(scheduler.prio_total < 0);
/* As soon as we schedule, we're gone */
preempt_enable();
schedule();
BUG();
}
/*
* NOTE: Could do these as sched_prepare_suspend()
* + schedule() or need_resched = 1

View File

@@ -31,8 +31,6 @@ void tcb_init(struct ktcb *new)
mutex_init(&new->thread_control_lock);
cap_list_init(&new->cap_list);
cap_list_init(&new->tgroup_cap_list);
cap_list_init(&new->pager_cap_list);
/* Initialise task's scheduling state and parameters. */
sched_init_task(new, TASK_PRIO_NORMAL);
@@ -71,8 +69,8 @@ void tcb_delete(struct ktcb *tcb)
BUG_ON(tcb->wqh_send.sleepers > 0);
BUG_ON(tcb->wqh_recv.sleepers > 0);
BUG_ON(!list_empty(&tcb->task_list));
BUG_ON(!list_empty(&tcb->rq_list));
BUG_ON(tcb->rq);
BUG_ON(!list_empty(&tcb->rq_list) && tcb != current);
BUG_ON(tcb->rq && tcb != current);
BUG_ON(tcb->nlocks);
BUG_ON(tcb->waiting_on);
BUG_ON(tcb->wq);