mirror of
https://github.com/drasko/codezero.git
synced 2026-11-28 11:53:53 +01:00
Cleanup on previous commits
This commit is contained in:
@@ -140,12 +140,12 @@ void handle_requests(void)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case L4_IPC_TAG_EXIT: {
|
case L4_IPC_TAG_EXIT: {
|
||||||
|
/* Pager exit test
|
||||||
struct task_ids ids;
|
struct task_ids ids;
|
||||||
|
|
||||||
l4_getid(&ids);
|
l4_getid(&ids);
|
||||||
|
|
||||||
printf("\n%s: Destroying self (%d), along with any tasks.\n", __TASKNAME__, self_tid());
|
printf("\n%s: Destroying self (%d), along with any tasks.\n", __TASKNAME__, self_tid());
|
||||||
l4_thread_control(THREAD_DESTROY, &ids);
|
l4_thread_control(THREAD_DESTROY, &ids);
|
||||||
|
*/
|
||||||
|
|
||||||
/* An exiting task has no receive phase */
|
/* An exiting task has no receive phase */
|
||||||
sys_exit(sender, (int)mr[0]);
|
sys_exit(sender, (int)mr[0]);
|
||||||
|
|||||||
+2
-71
@@ -232,7 +232,7 @@ void sched_resume_async(struct ktcb *task)
|
|||||||
*/
|
*/
|
||||||
void sched_pager_exit(void)
|
void sched_pager_exit(void)
|
||||||
{
|
{
|
||||||
printk("Pager (%d) Exiting...\n", current->tid);
|
// printk("Pager (%d) Exiting...\n", current->tid);
|
||||||
/* Remove from its list, callers get -ESRCH */
|
/* Remove from its list, callers get -ESRCH */
|
||||||
tcb_remove(current);
|
tcb_remove(current);
|
||||||
|
|
||||||
@@ -251,7 +251,7 @@ void sched_pager_exit(void)
|
|||||||
preempt_disable();
|
preempt_disable();
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* TOO LONG!
|
* FIXME: TOO LONG!
|
||||||
*/
|
*/
|
||||||
tcb_delete(current);
|
tcb_delete(current);
|
||||||
|
|
||||||
@@ -266,75 +266,6 @@ void sched_pager_exit(void)
|
|||||||
BUG();
|
BUG();
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
|
||||||
/*
|
|
||||||
* A paged-thread leaves the system and waits on
|
|
||||||
* its pager's task_dead queue.
|
|
||||||
*/
|
|
||||||
void sched_die_child(void)
|
|
||||||
{
|
|
||||||
int locked;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Find pager, he _must_ be there because he never
|
|
||||||
* quits before quitting us
|
|
||||||
*/
|
|
||||||
struct ktcb *pager = tcb_find(current->pagerid);
|
|
||||||
|
|
||||||
do {
|
|
||||||
/* Busy spin without disabling preemption */
|
|
||||||
locked = mutex_trylock(&pager->task_dead_mutex);
|
|
||||||
} while (!locked);
|
|
||||||
|
|
||||||
/* Remove from container task list,
|
|
||||||
* callers get -ESRCH */
|
|
||||||
tcb_remove(current);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* If the pager searches for us to destroy,
|
|
||||||
* he won't find us but he will block on the
|
|
||||||
* task_dead mutex when searching whether
|
|
||||||
* we died already.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* If there are any sleepers on any of the task's
|
|
||||||
* waitqueues, we need to wake those tasks up.
|
|
||||||
*/
|
|
||||||
wake_up_all(¤t->wqh_send, 0);
|
|
||||||
wake_up_all(¤t->wqh_recv, 0);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Add self to pager's dead tasks list,
|
|
||||||
* to be deleted by pager
|
|
||||||
*/
|
|
||||||
list_insert(¤t->task_list, &pager->task_dead_list);
|
|
||||||
|
|
||||||
/* Now quit the scheduler */
|
|
||||||
preempt_disable();
|
|
||||||
sched_rq_remove_task(current);
|
|
||||||
current->state = TASK_INACTIVE;
|
|
||||||
current->flags &= ~TASK_SUSPENDING;
|
|
||||||
scheduler.prio_total -= current->priority;
|
|
||||||
BUG_ON(scheduler.prio_total < 0);
|
|
||||||
preempt_enable();
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Clear pager waitqueue in case it issued
|
|
||||||
* a suspend on us (for any reason)
|
|
||||||
*/
|
|
||||||
wake_up(¤t->wqh_pager, 0);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Unlock task_dead queue,
|
|
||||||
* pager can safely delete us
|
|
||||||
*/
|
|
||||||
mutex_unlock(&pager->task_dead_mutex);
|
|
||||||
schedule();
|
|
||||||
BUG();
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
void sched_exit_sync(void)
|
void sched_exit_sync(void)
|
||||||
{
|
{
|
||||||
struct ktcb *pager = tcb_find(current->pagerid);
|
struct ktcb *pager = tcb_find(current->pagerid);
|
||||||
|
|||||||
@@ -117,7 +117,6 @@ int mutex_lock(struct mutex *mutex)
|
|||||||
* undeterministic as to how many retries will result in success.
|
* undeterministic as to how many retries will result in success.
|
||||||
* We may need to add priority-based locking.
|
* We may need to add priority-based locking.
|
||||||
*/
|
*/
|
||||||
//printk("Thread (%d) locking (%p) nlocks: %d\n", current->tid, mutex, current->nlocks);
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
spin_lock(&mutex->wqh.slock);
|
spin_lock(&mutex->wqh.slock);
|
||||||
if (!__mutex_lock(&mutex->lock)) { /* Could not lock, sleep. */
|
if (!__mutex_lock(&mutex->lock)) { /* Could not lock, sleep. */
|
||||||
@@ -132,7 +131,6 @@ int mutex_lock(struct mutex *mutex)
|
|||||||
|
|
||||||
/* Did we wake up normally or get interrupted */
|
/* Did we wake up normally or get interrupted */
|
||||||
if (current->flags & TASK_INTERRUPTED) {
|
if (current->flags & TASK_INTERRUPTED) {
|
||||||
//printk("XXXXXXXXXXXXXXXX (%d) Interrupted\n", current->tid);
|
|
||||||
current->flags &= ~TASK_INTERRUPTED;
|
current->flags &= ~TASK_INTERRUPTED;
|
||||||
return -EINTR;
|
return -EINTR;
|
||||||
}
|
}
|
||||||
@@ -142,14 +140,12 @@ int mutex_lock(struct mutex *mutex)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
spin_unlock(&mutex->wqh.slock);
|
spin_unlock(&mutex->wqh.slock);
|
||||||
//printk("Thread (%d) locked (%p) nlocks: %d\n", current->tid, mutex, current->nlocks);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void mutex_unlock_common(struct mutex *mutex, int sync)
|
static inline void mutex_unlock_common(struct mutex *mutex, int sync)
|
||||||
{
|
{
|
||||||
struct ktcb *c = current; if (c);
|
struct ktcb *c = current; if (c);
|
||||||
//printk("Thread (%d) unlocking (%p) nlocks: %d\n", c->tid, mutex, c->nlocks);
|
|
||||||
spin_lock(&mutex->wqh.slock);
|
spin_lock(&mutex->wqh.slock);
|
||||||
__mutex_unlock(&mutex->lock);
|
__mutex_unlock(&mutex->lock);
|
||||||
current->nlocks--;
|
current->nlocks--;
|
||||||
|
|||||||
Reference in New Issue
Block a user