Gavin Maltby wrote:


The call to preempt from sparc interrupt.s is to avoid interrupts running
endlessly on a cpu while pinning an interrupted thread (which could run
on another cpu if only we'd unpin it).  In sparc new interrupts can be
queued at the pil we're servicing even while we are serviving preexisting
requests (new requests come in at traplevel 1 via vec_interrupt).
x86 does not require this check.

Sorry, I'm not familiar with Sparc platform.

As I known, cmnint routine will mask same or below level's interrupt by calling psm_intr_enter.
Does it means sparc CPU don't mask the interrupt at same level?



That flag is t_astflag in the thread structure - you'll see it
checked in user_rtt for sparc and in lwp_rtt for x86.
Exactly how you get there is left as an exercise (ie it
is convoluted).


Yeah, after reading source code again, I know poke_cpu can cause other CPU's preemption via a crosscall.

Finally, I found the entry point of rtt code for x86 platform:

http://cvs.opensolaris.org/source/xref/on/usr/src/uts/i86pc/ml/interrupt.s

  536   ENTRY_NP2(cmnint, _interrupt)
537 538 INTR_PUSH

  ...........................
836 .intr_ret2:
  837   movl    CPU_SOFTINFO(%ebx), %edx
  838   orl     %edx, %edx
  839   jz      _sys_rtt   ------------------------> entry point of rtt code
  840   jmp     dosoftint
  841   SET_SIZE(cmnint)
  842   SET_SIZE(_interrupt)


In _sys_rtt code, if it return to user mode with t_astflag set, that will cause a AST trap:

 1916     /*
 1917      * Return to User.
 1918      */
 1919
 1920     ALTENTRY(sys_rtt_syscall)
 1921     /* check for an AST that's posted to the lwp */
 1922     movl    %gs:CPU_THREAD, %eax
 1923     cli                /* disable interrupts */
1924 cmpb $0, T_ASTFLAG(%eax) /* test for signal or AST flag */ --------------> t_astflag
 1925     jne    handle_ast
 1926
 ............................................
 1935
 1936 handle_ast:
 1937     /* Let trap() handle the AST */
 1938     sti                /* enable interrupts */
1939 movl $T_AST, REGOFF_TRAPNO(%esp) /* set trap type to AST */ 1940 movl %esp, %eax
 1941     pushl    %gs:CPU_ID
 1942     pushl    $0
 1943     pushl    %eax
1944 call trap /* trap(rp, 0, cpuid) */ --------------->AST trap
 1945     addl    $12, %esp
 1946     jmp    _sys_rtt

At last, return-from-trap code will call preemt if cpu_runrun set.

But poke_cpu is just called for other cpu, not current thread's cpu.

For current thread's cpu or a UP system, the user preemptions only happen when syscall, trap or interupt (typically, clock interrupt) return.
That's my understanding, is it right?


It seems AST trap is not only used for user preemtion but also for process signal mechanism. Maybe I can work out how it work in folloing days.

Anyway, your reply is valuable for me, thank you!

--
Cheers,

----------------------------------------------------------------------
Oliver Yang | OPG Engineering Operation | [EMAIL PROTECTED] | x82229

_______________________________________________
opensolaris-code mailing list
[email protected]
http://mail.opensolaris.org/mailman/listinfo/opensolaris-code

Reply via email to