mirror of
https://github.com/drasko/codezero.git
synced 2026-01-13 03:13:15 +01:00
exit() almost there.
- Implemented reasonable way to suspend task.
- A task that has a pending suspend would be interrupted
from its sleep via the suspender task.
- If suspend was raised and right after, task became about to sleep,
then scheduler wakes it up.
- If suspend was raised when task was in user mode, then an irq suspends it.
- Also suspends are checked at the end of a syscall so that if suspend was
raised because of a syscall from the task, the task is suspended before it
goes back to user mode.
- This mechanism is very similar to signals, and it may lead as a base for
implementing signal handling.
- Implemented common vma dropping for shadow vm object dropping and task exiting.
This commit is contained in:
@@ -28,7 +28,7 @@ int sys_thread_switch(syscall_context_t *regs)
|
||||
int thread_suspend(struct task_ids *ids)
|
||||
{
|
||||
struct ktcb *task;
|
||||
int ret;
|
||||
int ret = 0;
|
||||
|
||||
if (!(task = find_task(ids->tid)))
|
||||
return -ESRCH;
|
||||
@@ -36,17 +36,13 @@ int thread_suspend(struct task_ids *ids)
|
||||
if (task->state == TASK_INACTIVE)
|
||||
return 0;
|
||||
|
||||
/* First show our intention to suspend thread */
|
||||
/* Signify we want to suspend the thread */
|
||||
task->flags |= TASK_SUSPENDING;
|
||||
|
||||
/*
|
||||
* Interrupt the task in case it was sleeping
|
||||
* so that it will be caught and suspended by
|
||||
* the scheduler.
|
||||
*/
|
||||
wake_up_task(task, 1);
|
||||
/* Wake it up if it's sleeping */
|
||||
wake_up_task(task, WAKEUP_INTERRUPT | WAKEUP_SYNC);
|
||||
|
||||
/* Wait until scheduler wakes us up */
|
||||
/* Wait until task suspends itself */
|
||||
WAIT_EVENT(&task->wqh_pager,
|
||||
task->state == TASK_INACTIVE, ret);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user