PROCESS_MANAGEMENT.EXE/journal=preempt_resume
!
!	Patch to module SCHED (SCH$RESCHED) ...
!		... in PROCESS_MANAGEMENT.EXE (VMS V5)
!	Also refers to module RSE (SCH$QEND).
!
!	w.j.m. jul 1994 (from 6.1 listing CD)
!
!	Intention of this patch:
!		Insert preempted processes at HEAD of priority queue
!		(instead of TAIL, as has always been done in VMS).
!
!	IMPORTANT NOTE: For a VAX with a VECTOR processor, first apply
!			the "VECTOR_QUANT" patch, unless you really want
!			vector consumers to be favored by a factor of 32!
!			Setting bit 9 of SCH_CTLFLAGS _may_ also help.
!
! This patch is valid for:
!	VAX/VMS 6.1
!
!
define	IPL$_RESCHED = 03
define	PR$_SIRR = 014		! software interrupt request
!
define	PCB$L_STS2 = 028
define	PCB$V_QUANTUM_RESCHED = 0
define	PCB$M_QUANTUM_RESCHED = 1@PCB$V_QUANTUM_RESCHED
!
define	PCB$B_SCHED_POLICY = 0128
define	PCB$K_SCHED_OTHER = 0
!
define	SCH$AQ_COMT = 080004974
define	SCH$GL_IDLE_CPUS = 080004EC0
!
define	PCB$V_IN_TBS_STATE = 0E
define	PCB$V_WINDFALL = 0F
define	SCH$GL_TBSH = 800053DC
define	SCH$GL_TBSWH = 800053E0
!
define resched_12$ = SCH$RESCHED + 09B
define resched_14$ = SCH$RESCHED + 0A0
define resched_15$ = SCH$RESCHED + 0A3
define resched_20$ = SCH$RESCHED + 0B9
!
set eco 105
!
verify/instr SCH$QEND-0732 + 0849	! bit set here
'bisb2	#PCB$M_QUANTUM_RESCHED,b^PCB$L_STS2(r4)'
'mtpr	#IPL$_RESCHED,#PR$_SIRR'	! (SOFTINT macro)
'rsb'
exit
!
verify/instr SCH$QEND-0732 + 076C	! bit set here
'bisl2	#PCB$M_QUANTUM_RESCHED,b^PCB$L_STS2(r4)'
'mtpr	#IPL$_RESCHED,#PR$_SIRR'	! (SOFTINT macro)
'rsb'
exit
!
verify/instr SCH$RESCHED + 074
'movaq	@#SCH$AQ_COMT[r0],r2'
'cmpb	w^PCB$B_SCHED_POLICY(r1),#PCB$K_SCHED_OTHER'
'bneq	resched_20$'
'bbc	#PCB$V_IN_TBS_STATE,b^PCB$L_STS2(r1),resched_14$'
'movl	@#SCH$GL_TBSH,r2'
'bbc	#PCB$V_WINDFALL,b^PCB$L_STS2(r1),resched_12$'
'movl	@#SCH$GL_TBSWH,r2'
'movaq	b^4(r2)[r0],r2'			! this is resched_12$
'insque	(r1),@(r2)+'			! this is resched_14$
'clrl	@#SCH$GL_IDLE_CPUS'		! this is resched_15$
exit
!
verify/instr resched_12$
'movaq	b^4(r2)[r0],r2'
exit
!.061
!
verify/instr resched_14$
'insque	(r1),@(r2)+'
exit
!
verify/instr resched_15$
'clrl	@#SCH$GL_IDLE_CPUS'
exit
!
verify/instr resched_20$		! want this code to be always executed
'bbsc	#PCB$V_QUANTUM_RESCHED,b^PCB$L_STS2(r1),resched_14$'
'insque	(r1),b^-4(r2)'
'brb	resched_15$'
exit
!
replace/instr SCH$RESCHED + 83
'bbc	#PCB$V_IN_TBS_STATE,b^PCB$L_STS2(r1),resched_14$'
exit
'bbc	#PCB$V_IN_TBS_STATE,b^PCB$L_STS2(r1),resched_20$'
exit
!
!
update
!
exit
