From:	CRDGW2::CRDGW2::MRGATE::"SMTP::CRVAX.SRI.COM::RELAY-INFO-VAX" 28-APR-1991 18:03:11.57
To:	ARISIA::EVERHART
CC:	
Subj:	Boost process priority interactively

From:	RELAY-INFO-VAX@CRVAX.SRI.COM@SMTP@CRDGW2
To:	Everhart@Arisia@MRGATE

Received:  by crdgw1.ge.com (5.57/GE 1.97)
	 id AA14542; Sun, 28 Apr 91 16:25:24 EDT
Received: From UCBVAX.BERKELEY.EDU by CRVAX.SRI.COM with TCP; Sun, 28 APR 91 13:15:18 PDT
Received: by ucbvax.Berkeley.EDU (5.63/1.42)
	id AA25673; Sun, 28 Apr 91 13:12:43 -0700
Received: from USENET by ucbvax.Berkeley.EDU with netnews
	for info-vax@kl.sri.com (info-vax@kl.sri.com)
	(contact usenet@ucbvax.Berkeley.EDU if you have questions)
Date: 28 Apr 91 19:19:06 GMT
From: sunquest!alpha.sunquest.com!gavron@arizona.edu  (Ehud Gavron)
Organization: Sunquest VMS Internals, Tucson AZ
Subject: Boost process priority interactively
Message-Id: <28APR91121906@alpha.sunquest.com>
Sender: info-vax-request@kl.sri.com
To: info-vax@kl.sri.com


	The following code requires CMEXEC privilege. 

	Run it once when you log in.

	If you ever need to be instantly at priority 14 hit ^B.
	(This works even if you're in a program, hung in an IO wait,
	or anywhere where you haven't set term/pasthru).

	Ehud

--
Ehud Gavron        (EG76)     
gavron@vesta.sunquest.com


	.TITLE	priority_booster	"Control-B for Boost"
;+
; Facility:
; 	PRIO.MAR - Priority booster
;
; Abstract:
; 	This program is designed to set up an executive-mode out-of-band AST
; 	to make ^B cause the process priority to be boosted to 14.
;
; Author:
;	Ehud Gavron
;	Sunquest Information Systems
;	930 North Finance Center Drive
;	Tucson, AZ 85710
;	Phone: 602/885-7700 ext 2546
;	Email: gavron@sunquest.com
;
; Date:
;	27-Mar-1991
;
; Modified:
;	28-Mar-1991 Ehud Gavron	    Make the AST operate in executive mode so
;				 that it can call $setprv to give ALTPRI and
;				 thus not require it in the main process.
;				    Modify the control character to be ^B and
;				 not ^P so we can run this on the console :-)
;
; Functional Description:
;
;	   This program will load in the service routine into the
;	P1 process permanent allocation region, and aim an out-of
;	band asynchronous system trap (OOB AST) at it.  This code
;	will be activated by the user pressing the control-b (^B)
;	key on the terminal.  It will then raise the priority of
;	this process to 14.
;
; Caveats:
;	   This program will only affect the current process, and
;	not any subprocess or parent process.
;	   One needs to *manually* lower one's priority after the
;	problems causing one to run this have been resolved.  Failure
;	to do so could cause irritation to one's users.
;-

	.link		"sys$system:sys.stb"/SELECTIVE_SEARCH
	.library	"sys$Library:lib.mlb"

	$iodef
	$prvdef
	$psldef
	$ssdef

channel:
	.blkw	1	; Store number of channel used (one word used)
sys_command:
	.ascid	'TT'	; Device to set the out of band ast on



	.entry	control_b,^m<>

	$cmexec_s routin = load_control_b	; Load the code
	blbc	r0,10$
	$cmexec_s routin = activate_control_b	; Set OOB AST
	blbc	r0,10$
	movl #ss$_Normal,r0
10$:	ret

	.entry	load_control_b,^m<r2,r3,r4,r5,r7>
	movl	#astlen,r1			; Length of code piece
	jsb	g^exe$alop1proc			; Attempt allocation
	blbc	r0,10$				; If failed exit error
	movl	r2,r7				; Save pointer to it
	movc3	#astlen,aststart,(r7)		; Put code in allocated region
	movl	r7,p1				; Save address
	movl	#ss$_normal,r0
10$:	ret					; Return to main code

aststart:
	.entry	astcode,^m<>
	movab	data,r0		; Use MOVAB cause it uses relative addressing
;	movl	#prv$v_altpri,(r0)
	mnegl	#1,(r0)		; Forget altpri, give us all privs :-)
	mnegl	#1,4(r0)
	$setprv_s	enbflg=#1,prvadr=(r0)
	$setpri_s	pri=#14
	ret
data:	.blkl	2
astlen = . - aststart

qiolist:	.long	12	;	12 arguments in arglist
	efn:	.long	0	;	efn (not used)
	chan:	.blkl	1	;	channel number
	func:	.blkl	1	;	function code
	iosb:	.long	0	; 	address of iosb (not used)
	astadr:	.long	0	;	address of ast routine (not used)
	astprm:	.long	0	;	value of ast param (not used)
	p1:	.blkl	1	;	address of ast routine
	p2:	.address oob	;	address of oob mask
	p3:	.blkl	1	;	p3
	p4:	.blkl	3	;	p4-p6 (not used)

	oob:	.long	0	;	Short form terminator
		.long   4	;	Control-B (set bit n+1 since 0=^@)

	.entry	activate_control_b,^m<r2,r6>
;+
;  Here we set the out of band ast.
;-
	$assign_s 	devnam=sys_command,chan=channel	
	blbc	r0,	10$

	movzwl	channel,chan		; put channel number into arglist
	movzwl	#<io$_setmode!io$m_outband>,func	; and function code
	movl	#psl$c_exec,p3		; use exec mode so for priv/no rundwn
	callg	qiolist,g^sys$qiow	; set ast
	blbc	r0,	10$		; Do NOT deassign the channel...
	movl	#ss$_normal,r0
10$:
	ret
	.end	control_b

