Opened 16 years ago
Last modified 15 years ago
#11 closed enhancement
Handle exceptions through a context switch — at Initial Version
Reported by: | Nicolas Pouillon | Owned by: | Nicolas Pouillon |
---|---|---|---|
Priority: | minor | Milestone: | Preemptive scheduler usage |
Component: | hexo | Keywords: | |
Cc: |
Description
There are three main types of exception/interrupts:
- hardware interrupts
- program exception (sysreq, faults, traps, ...)
We'll need to be able to switch from a task to another when handling exceptions, this is because of different needs, but in the end is wanted:
- syscall triggering a device action, thus making the task non-eligible to scheduling until the request ends
- syscall begin sched_switch() or yield()
- page fault triggering a page refill
Sometimes for hardware interrupts, we want to be able to switch tasks as well (eg timer + preempt)
Unfortunately, we cant do most of these jobs directly from the exception handlers because some CPUs (arm) use a special stack pointer when handling interrupts and exceptions. We dont want to loose time in IRQ processing, so we'll spend more time in exception processing.
We could handle all this a portable and easy way if we had an exception/syscall/whatever-handling thread. On exception/syscall, we can switch to this thread, passing arguments and state through cpu-local variables. This could make thread switching easy.
This does not concern IRQs, which must be as-quick as possible. But as we sometimes have to switch threads on IRQ, we should add a mecanism allowing the IRQ handler to request a system service ASAP. Then directly in the asm IRQ handling code, we can detect this service request, and make the IRQ handler jump to the syscall code rather than returning to the user code.