PROCESS_MANAGEMENT.EXE
!
!	Patch to module SCHED (SCH$RESCHED) ...
!		... in PROCESS_MANAGEMENT.EXE (VMS V5)
!
!	w.j.m. may 1991
!
!	Intention of this patch:
!		Insert preempted processes at HEAD of priority queue
!		(instead of TAIL, as has always been done in VMS).
!
! This patch is valid for:
!	VMS 5.4,-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	SCH$AQ_COMT = 080004974
define	SCH$GL_IDLE_CPUS = 080004EC0
!
define	ECO105_9$ = SCH$RESCHED + 07A
!
set eco 105
!
verify/instr SCH$QEND-068B + 0773	! bit is set here (also in EXE$RESCHED)
'bisb2	#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'
'insque	(r1),@(r2)+'
'clrl	@#SCH$GL_IDLE_CPUS'
exit
verify/instr ECO105_9$
'clrl	@#SCH$GL_IDLE_CPUS'
exit
!
set patch PAT$A_NONPAGED
!
replace/ins SCH$RESCHED + 077
'insque	(r1),@(r2)+'
exit
'bbcc	#PCB$V_QUANTUM_RESCHED,b^PCB$L_STS2(r1),ECO105_1$'	! br if preempted
'insque	(r1),@(r2)+'			! quantum end - insert at TAIL of queue
'brw	ECO105_9$'
'ECO105_1$:	insque	(r1),b^-4(r2)'	! preempted - insert at HEAD of queue
'brw	ECO105_9$'
exit
!
update
!
exit
