Damien Zammit, le sam. 05 août 2023 16:16:41 +0000, a ecrit: > If the current processor is not the one we want to run an ast on, > we can bind the current thread to the processor we want, and force a > thread switch to that one, then run the ast_check() on the right cpu.
Err, that's an expensive way of doing it. ast_check() does *not* need to be executed by this particular thread, it is a per-processor check. So all we need to do is to send an IPI that makes the other processor call ast_check(), whatever the context there. > --- > i386/i386/ast_check.c | 13 +++++++++++-- > 1 file changed, 11 insertions(+), 2 deletions(-) > > diff --git a/i386/i386/ast_check.c b/i386/i386/ast_check.c > index 5121abf1..1b80ea4a 100644 > --- a/i386/i386/ast_check.c > +++ b/i386/i386/ast_check.c > @@ -28,12 +28,11 @@ > > /* > * Handle signalling ASTs on other processors. > - * > - * Initial i386 implementation does nothing. > */ > > #include <kern/ast.h> > #include <kern/processor.h> > +#include <kern/thread.h> > > /* > * Initialize for remote invocation of ast_check. > @@ -47,6 +46,16 @@ void init_ast_check(const processor_t processor) > */ > void cause_ast_check(const processor_t processor) > { > + thread_t this_thread = current_thread(); > + > + if (current_processor() != processor) { > + thread_bind(this_thread, processor); > + thread_block(thread_no_continuation); > + } > + > + ast_check(); > + > + thread_bind(this_thread, PROCESSOR_NULL); > } > > #endif /* NCPUS > 1 */ > -- > 2.40.1