On Thursday, June 11, 2015 04:50:52 PM Stefan Andritoiu wrote:
> Hello,
> 
> From the FreeBSD Handbook: "FreeBSD deals with interrupt handlers by
> giving them their own thread context".
> From my understanding when a IPI is received the thread that will run
> it is placed on the real-time runq, and the scheduler will be invoked
> to schedule it.
> 
> So the sequence should be:
> currently running thread -> scheduler thread -> interrupt handler ->
> scheduler thread -> previously interrupted thread (if no thread
> priority change took place inside the interrupt handler)
> 
> Is this correct?

(Sorry these replies are dated.)

IPIs do not run in a dedicated thread.  Only device interrupt handlers
run in a dedicated thread.  IPIs (and some device handlers such as timer
interrupts) borrow the stack of the currently executing thread to run
their handler.  As a result, you should have no context switches when
an IPI is received unless the IPI handler specifically invokes one.

One IPI that explicitly swithes is IPI_PREEMPT.  However, other IPIs can
result in a switch if the interrupted thread is running in userland and
a context switch to another thread is performed via the checks in
userret() and/or ast().  This is how IPI_AST is used.  It has a NULL
handler and is only sent to trigger the side effects in userret() in
case the thread is executing in userland.

-- 
John Baldwin
_______________________________________________
freebsd-virtualization@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-virtualization
To unsubscribe, send any mail to 
"freebsd-virtualization-unsubscr...@freebsd.org"

Reply via email to