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. aug 1992 (from 5.5 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!
!		
! This patch is valid for:
!	VMS 5.5,-1,-2
!
!
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 resched_14$ = SCH$RESCHED + 07E
define resched_15$ = SCH$RESCHED + 081
define resched_20$ = SCH$RESCHED + 08A
!
set eco 105
!
verify/instr SCH$QEND-06C0 + 07B6	! 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-06C0 + 06FA	! 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 + 06F
'movaq	@#SCH$AQ_COMT[r0],r2'
'cmpb	w^PCB$B_SCHED_POLICY(r1),#PCB$K_SCHED_OTHER'
'bneq	resched_20$'
'insque	(r1),@(r2)+'			! this is resched_14$
'clrl	@#SCH$GL_IDLE_CPUS'		! this is resched_15$
exit
!
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 + 06F
'movaq	@#SCH$AQ_COMT[r0],r2'
'cmpb	w^PCB$B_SCHED_POLICY(r1),#PCB$K_SCHED_OTHER'
'bneq	resched_20$'
exit
'movaq	@#SCH$AQ_COMT[r0],r2'
'brb	resched_20$'
exit
!
update
!
exit
