From:	CSBVAX::CSBVAX::MRGATE::"SMTP::CRVAX.SRI.COM::RELAY-INFO-VAX" 20-JAN-1989 22:53
To:	MRGATE::"ARISIA::EVERHART"
Subj:	long term scheduler - part 1 of 5


Received: From KL.SRI.COM by CRVAX.SRI.COM with TCP; Thu, 19 JAN 89 20:26:10 PDT
Received: from RELAY.CS.NET by KL.SRI.COM with TCP; Thu, 19 Jan 89 20:21:53 PST
Received: from relay2.cs.net by RELAY.CS.NET id br21839; 19 Jan 89 20:40 EST
Received: from a.cs.okstate.edu by RELAY.CS.NET id aa18099; 19 Jan 89 19:12 EST
Received: from nemo.math.okstate.edu by a.cs.okstate.edu id aa10439;
          19 Jan 89 9:42 CST
Date: Thu, 19 Jan 89 09:37 CDT
From: Gregg Wonderly <GREGG%nemo.math.okstate.edu@RELAY.CS.NET>
Subject: long term scheduler - part 1 of 5
To: info-vax@KL.SRI.COM
X-VMS-To: in%"info-vax@kl.sri.com"

...................... Cut between dotted lines and save ......................
$!.............................................................................
$! VAX/VMS archive file created by VMS_SHAR V-5.03 07-Oct-1987
$! which was written by Michael Bednarek (U3369429@ucsvc.dn.mu.oz.au)
$! To unpack, simply save and execute (@) this file.
$!
$! This archive was created by GREGG
$! on Thursday 19-JAN-1989 09:01:03.66
$!
$! ATTENTION: To keep each article below 61440 bytes, this program
$! has been transmitted in 4 parts.
$! You should concatenate ALL parts to ONE file and execute (e.g. @filename) that file.
$!
$! It contains the following 27 files:
$! GDATA.INC GDATA.MAR GDATA.OPT GDATA_SHARE.OPT GETPROC.MAR MACRO.MAR MAKE.COM
$! MBX.MAR PARAMS.INC SCHCMD.FOR SCHED.FOR SCHED_ERR.MSG SLEEP.MAR SMG.DIR
$! SMGDEF.TXT STATEDEF.INC STRUCT.INC STRUCT.MAR BEGIN_DATA.FOR BLENGTH.FOR
$! END_DISPLAY.FOR END_SMG.FOR INIT_DISPLAY.FOR PUT_DATA.FOR PUT_QUEUE.FOR
$! RESET_DISPLAY.FOR SMG_START.FOR
$!=============================================================================
$ Set Symbol/Scope=(NoLocal,NoGlobal)
$ Version=F$GetSYI("VERSION") ! See what VMS version we have here:
$ If Version.ges."V4.4" then goto Version_OK
$ Write SYS$Output "Sorry, you are running VMS ",Version, -
                ", but this procedure requires V4.4 or higher."
$ Exit 44
$Version_OK: CR[0,8]=13
$ Pass_or_Failed="failed!,passed."
$ Goto Start
$Convert_File:
$ Read/Time_Out=0/Error=No_Error1/Prompt="creating ''File_is'" SYS$Command ddd
$No_Error1: Define/User_Mode SYS$Output NL:
$ Edit/TPU/NoSection/NoDisplay/Command=SYS$Input/Output='File_is' -
        VMS_SHAR_DUMMY.DUMMY
set(Informational, off); set (success, off);
f:=Get_Info(Command_Line,"File_Name"); b:=Create_Buffer("",f);
o:=Get_Info(Command_Line,"Output_File"); Set(Output_File,b,o);
Position(Beginning_of(b)); Loop x:=Erase_Character(1);
Loop ExitIf x<>"V"; Move_Vertical(1); x:=Erase_Character(1);
Append_Line; Move_Horizontal(-Current_Offset);
EndLoop; Move_Vertical(1); ExitIf Mark(None)=End_of(b)
EndLoop; Position(Beginning_of(b)); Loop
x:=Search("`",Forward,Exact); ExitIf x=0; Position(x);
Erase_Character(1); If Current_Character='`' then Move_Horizontal(1);
else Copy_Text(ASCII(INT(Erase_Character(3)))); EndIf; EndLoop; Exit;
$ Delete VMS_SHAR_DUMMY.DUMMY;*
$ Checksum 'File_is
$ Success=F$Element(Check_Sum_is.eq.CHECKSUM$CHECKSUM,",",Pass_or_Failed)+CR
$ Read/Time_Out=0/Error=No_Error2/Prompt=" CHECKSUM ''Success'" SYS$Command ddd
$No_Error2: Return
$Start:
$ File_is="GDATA.INC"
$ Check_Sum_is=490040677
$ Copy SYS$Input VMS_SHAR_DUMMY.DUMMY
X        include 'params.inc'
X        include 'struct.inc'
X
X        integer sysgrp, pids, sumtime, interval, queuecnt, min_percent
X        integer max_percent, up_prio, down_prio, io_diff, curcnt, min_time
X        integer down_count, hog_count, hog_prio, idle_cnt, my_pid, max_active
X        logical*4 stopnow, sch_running
X
X        record /proc_info/ procs(0:MAX_PROCS)
X        record /prev_info/ prev(0:MAX_PROCS)
X        record /queue_info/ queues(0:MAX_QUEUES)
X
X        common /gdata/ sysgrp, pids, sumtime, interval, stopnow, queuecnt,
X     .                 max_percent, min_percent, up_prio, down_prio, io_diff,
X     .                 curcnt, sch_running, min_time, my_pid,
X     .                 down_count, hog_count, hog_prio, idle_cnt, max_active,
X     .                 procs, prev, queues
$ GoSub Convert_File
$ File_is="GDATA.MAR"
$ Check_Sum_is=1177837190
$ Copy SYS$Input VMS_SHAR_DUMMY.DUMMY
X;
X;`009Things others need to know about
X;
X`009`009.global pids,sysgrp,sumtime,interval,queuecnt,stopnow
X`009`009.global max_percent,min_percent, curcnt, gdata
X`009`009.global up_prio, down_prio, io_diff, procs, prev
X`009`009.global`009sch_running, queues, gdata_end, min_time
X`009`009.global down_count, hog_count, hog_prio, idle_cnt
X`009`009.global my_pid
X
X;
X;`009GDATA common area used to pass things around in FORTRAN
X;
X                .psect  gdata,pic,ovr,rel,gbl,shr,noexe,rd,wrt,long
X;
Xgdata:
Xsysgrp=.-gdata
X`009`009.long`0090`009; MAX_SYSGRP SYSGEN parameter
Xpids=.-gdata
X`009`009.long`0090`009; Context variable for $GETJPI
Xsumtime=.-gdata
X`009`009.long   0`009; Total CPU consumed by considered processes
Xinterval=.-gdata
X`009`009.long`0090`009; Wake up interval
Xstopnow=.-gdata
X`009`009.long`0090`009; Flag saying SCHED/STOP was issued
Xqueuecnt=.-gdata
X`009`009.long   0`009; Count of queues requiring processing
Xmax_percent=.-gdata
X`009`009.long`0090`009; Maximum CPU usage before downgrade
Xmin_percent=.-gdata
X`009`009.long`0090`009; Minimum CPU usage before upgrade
Xup_prio=.-gdata
X`009`009.long`0090`009;Priority during NON-CPU bound execution
Xdown_prio=.-gdata
X`009`009.long`0090`009;Priority during CPU bound execution
Xio_diff=.-gdata
V`009`009.long`0090`009;Minimum difference in BASE and CUR PRIO before downgrad
Xe
Xcurcnt=.-gdata
X`009`009.long   0`009;Current number of watched processes
Xsch_running=.-gdata
X`009`009.long`0090`009;Flag for whether scheduler is running
Xmin_time=.-gdata
X`009`009.long`0090`009;Minimum CPU required before consideration
Xmy_pid=.-gdata
X`009`009.long`0090`009;Process ID of scheduler
Xdown_count=.-gdata
X        .long   0`009;Value of /DOWNCOUNT
Xhog_count=.-gdata
X`009`009.long`0090`009;/HOG_COUNT
Xhog_prio=.-gdata
X`009`009.long`0090`009;/HOG_PRIO
Xidle_cnt=.-gdata
X`009`009.long`0090`009;/IDLE_COUNT
Xmax_active=.-gdata
X        .long   0   ;/MAX_ACTIVE
X
XMAX_PROCS`009= 50
XMAX_QUEUES`009= 10
XLONG_SIZE`009= 4
XMAX_IMAGE`009= 250
X
XPROC_INFO_LEN`009= 7*LONG_SIZE+14+MAX_IMAGE
XPREV_INFO_LEN`009= <13*LONG_SIZE>+14+<5*LONG_SIZE>
XQUEUES_LEN`009= <9*LONG_SIZE>+100
X
XPROC_SIZE=<MAX_PROCS+1>*PROC_INFO_LEN
XPREV_SIZE=<MAX_PROCS+1>*PREV_INFO_LEN
XQUEUES_SIZE=<MAX_QUEUES+1>*QUEUES_LEN
X
Xprocs=.-gdata
X`009`009.blkb   PROC_SIZE
Xprev=.-gdata
X`009`009.blkb   PREV_SIZE
Xqueues=.-gdata
X`009`009.blkb   QUEUES_SIZE
X;
X;`009Ending offset for psect
X;
Xgdata_end=.-gdata
X`009`009.end
$ GoSub Convert_File
$ File_is="GDATA.OPT"
$ Check_Sum_is=889848352
$ Copy SYS$Input VMS_SHAR_DUMMY.DUMMY
Xsched$root:[exe]sched$gdata/share
Xuniversal=sysgrp,pids,sumtime,interval,stopnow,queuecnt,max_percent
Xuniversal=min_percent,up_prio,down_prio,io_diff,procs,prev,gdata,gdata_end
Xuniversal=queues,min_time,down_count,hog_count,hog_prio,idle_cnt,my_pid
$ GoSub Convert_File
$ File_is="GDATA_SHARE.OPT"
$ Check_Sum_is=1934515241
$ Copy SYS$Input VMS_SHAR_DUMMY.DUMMY
Xgdata.obj
Xuniversal=sysgrp,pids,sumtime,interval,stopnow,queuecnt,max_percent
Xuniversal=min_percent,up_prio,down_prio,io_diff,procs,prev,gdata,gdata_end
Xuniversal=queues,min_time,down_count,hog_count,hog_prio,idle_cnt,my_pid
$ GoSub Convert_File
$ File_is="GETPROC.MAR"
$ Check_Sum_is=202700511
$ Copy SYS$Input VMS_SHAR_DUMMY.DUMMY
X`009`009.title`009Sched
X`009`009.ident`009"1.0"
X`009`009.library /sys$library:lib/
X
X`009`009$ssdef
X`009`009$jpidef
X`009`009$prvdef
X`009`009$statedef
X;
V;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
X;;
X;
X;`009This file contains the routines get_proc_info and getsysgrp.
X;
V;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
X;;
X;
X;`009Item list macro for $GETJPI and $GETSYI
X;
X`009`009.macro`009jpient,code,len,bufaddr,retlenaddr
X`009`009.word`009len,code
X`009`009.address -
X`009`009`009bufaddr
X`009`009.address -
X`009`009`009retlenaddr
X`009`009.endm
X;
X;`009Some constant parameters
X;
Xmaxulen=14`009`009`009; Maximum username length
Xmaximage=250`009`009; Maximum length of an image name
X
X`009`009.psect`009data,rd,wrt,noexe
X;
X;`009All information needed about each process from $GETJPI
X;
Xjpilist1:
X`009`009jpient`009JPI$_UIC,4,uic,dumlen
X`009`009jpient`009JPI$_CPUTIM,4,cputim,dumlen
X`009`009jpient`009JPI$_CURPRIV,8,curpriv,dumlen
X`009`009jpient`009JPI$_MODE,4,mode,dumlen
X`009`009jpient`009JPI$_OWNER,4,owner,dumlen
X;`009`009.long`0090,0
X;
X;jpilist2:
X`009`009jpient`009JPI$_STATE,4,state,dumlen
X`009`009jpient`009JPI$_PID,4,pid,dumlen
X`009`009jpient`009JPI$_PRI,4,pri,dumlen
X`009`009jpient`009JPI$_PRIB,4,prib,dumlen
X`009`009jpient`009JPI$_IMAGECOUNT,4,imagecnt,dumlen
X`009`009jpient`009JPI$_USERNAME,maxulen,username,unamlen
X`009`009jpient`009JPI$_IMAGNAME,maximage,imagname,imagelen
X`009`009.long`0090,0
X;
X;`009Information needed from $GETSYI
X;
Xsyilist:
X`009`009jpient`009SYI$_MAXSYSGROUP,4,0,dumlen
X`009`009.long`0090,0
X;
X;`009Values returned by $GETJPI.  WARNING, these values are in a specific
X;`009order, don't change them.  These match the structure declaration in
X;`009struct.inc so that MOVC3 can be used to copy the data.
X;
Xstatbuf:
Xcputim:`009`009.long`0090
Xpid:`009`009.long`0090
Xpri:`009`009.long`0090
Xprib:`009`009.long`0090
Xuic:`009`009.long`0090
Ximagecnt:`009.long`0090
Xstate:`009`009.long`0090
Xusername:`009.blkb`009maxulen
Ximagname:`009.blkb`009maximage
Xproc_buf_len=.-statbuf
X;
X;`009Other miscellaneous data for local use
X;
Ximagelen:`009.long`0090
Xunamlen:`009.long`0090
Xmode:`009`009.long`0090
Xcurpriv:`009.quad`0090
X;
Xtermlen:`009.long`0090
X;
Xdumlen:`009`009.long`0090`009; Dummy location for constant length items
Xowner:`009`009.long`0090
X;
X;`009Any processes with one or more of these privilges is ignored.
X;
Xprivmask:`009.long`009PRV$M_BYPASS
X`009`009.long`0090
X;
V;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
X;
X;
X;`009Get the MAXSYSGRP SYSGEN parameter and return it.  This is used to
X;`009determine what processes to ignore based on their group being in one
X;`009of the SYSTEM groups.
X;
V;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
X;
X;
X`009`009.psect`009exec,exe,rd,nowrt
X`009`009.entry`009getsysgrp,^m<>
X
X`009`009moval`009g^gdata,r1
X`009`009movab`009sysgrp(r1),r1
X`009`009movl`009r1,syilist+4
X`009`009$getsyiw_s -`009`009`009; Get needed system info
X`009`009`009itmlst=syilist
X`009`009blbs`009r0,10$
X`009`009pushl`009r0
X`009`009calls`009#1,g^lib$signal
X10$:
X;
X                ret`009`009`009`009; Return status in R0
X;
V;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
X;
X;
X;`009Get the next process that should be considered.  The value at 'pids'
X;`009is set to -1 elsewhere for the first time, and then left alone for
X;`009successive calls to this routine.  This routine does all of the
X;`009deciding on what processes to consider.  Currently, one of the
X;`009following attributes causes a process to be ignored.
X;
X;`009`0091. cputim < min_time
X;`009`0092. uic.grp <= sysgrp
X;`009`0093. has bypass privilege enabled 
X;`009`0094. is not an interactive process
X;
V;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
X;
X;
X
X`009`009.entry`009get_proc_info,^m<r2,r3,r4,r5,r6,r7,r8>
X;
X10$:
X`009`009moval`009g^gdata,r6
X`009`009$getjpiw_s -`009`009`009; Get some of the info
X`009`009`009pidadr=pids(r6),-`009; about the next process
X`009`009`009itmlst=jpilist1
X
X`009`009blbs`009r0,30$`009`009`009; Branch on NO error
X`009`009brw`00970$`009`009`009; Go test for SS$_NOMOREPROC
X;
X30$:
X`009`009cvtwl`009uic+2,r2`009`009; Get group field
X`009`009cmpl`009r2,sysgrp(r6)`009`009; Check against system group
X`009`009bleq`00910$`009`009`009; Skip SYSTEM processes
X;
X`009`009movl`009#-1,r2`009`009`009; Get all ones
X`009`009bicl`009privmask,r2`009`009; Clear the priv bits needed
X`009`009movl`009curpriv,r3`009`009; Get the current privs
X`009`009bicl`009r2,r3`009`009`009; Reset all but special privs
X`009`009tstl`009r3`009`009`009; Check for zero
X`009`009bneq`00910$`009`009`009; Ignore this process it has
X;
X;       Not needed until there are more priviledges used
X;
X;`009`009movl`009#-1,r2
X;`009`009bicl`009privmask+4,r2
X;`009`009movl`009curpriv+4,r3
X;`009`009bicl`009r2,r3
X;`009`009tstl`009r3
X;`009`009bneq`00910$
X;
X`009`009cmpl    cputim,min_time(r6)`009; Ignore process that have
X`009`009bgtr`00940$`009`009`009; accumulated a small amount
X`009`009tstl`009owner
X`009`009beql`00910$
X40$:
X`009`009movl`009mode,r2`009`009`009; Check the mode
X`009`009cmpl`009r2,#JPI$K_BATCH
X`009`009bneq`00960$`009`009`009; Jump if interactive,
X`009`009`009`009`009`009; network or other
X`009`009brw`00910$`009`009`009; Ignore batch jobs
X60$:
X;`009`009$getjpiw_s -`009`009`009; Get the rest of the info
X;`009`009`009pidadr=pids(r6),-`009; about the next process
X;`009`009`009itmlst=jpilist2
X;
X;`009`009blbs`009r0,61$`009`009`009; Branch on NO error
X;`009`009brw`00970$`009`009`009; Go test for SS$_NOMOREPROC
X;61$:
X`009`009movab`009username,r1`009`009; Make sure a space exists
X`009`009movl`009unamlen,r0`009`009; at the end of the username
X`009`009cmpl`009r0,#maxulen
X`009`009bgeq`00962$
X`009`009movb`009#32,0(r1)[r0]`009`009; Put in a space
X62$:
X`009`009movab`009imagname,r8`009`009; Make sure a space exists
X`009`009movl`009imagelen,r7`009`009; at the end of the username
X`009`009movl`009#maximage,r2
X`009`009cmpl`009r7,r2
X`009`009bgeq`00965$
X`009`009subl2`009r7,r2
X`009`009decl`009r2
X`009`009movb`009#32,0(r8)[r7]`009`009; Put in a space
X`009`009movc3`009r2,0(r8)[r7],1(r8)[r7]`009; Fill to the end
X65$:
X`009`009movl`0094(ap),r1`009`009; Get the buffer address
X`009`009movc3`009#proc_buf_len,statbuf,(r1)`009; Copy the information
X`009`009clrl`009r0`009`009`009; Set false condition for return
X`009`009brw`009getp_out`009`009; indicating there is more to come
X;
X;`009Control comes to here when $GETJPI returns an odd return code.
X;`009We check the ones that we know how to handle, and skip on the rest.
X;
X70$:
X`009`009cmpl`009r0,#SS$_NOMOREPROC`009; All done?
X                beql    80$`009`009`009; Jump if so
X                cmpl    r0,#SS$_BADPARAM`009; Programming error?
X`009`009beql`009err`009`009`009; Jump if so
X                cmpl    r0,#SS$_ACCVIO`009`009; Same?
X`009`009beql`009err`009`009`009; Jump if so
X                cmpl    r0,#SS$_NOPRIV`009`009; Same?
X`009`009beql`009err`009`009`009; Jump if so
X`009`009brw`00910$`009`009`009; Skip the process (swapped?)
X80$:
X`009`009movl`009#1,r0`009`009`009; Set true condition
X`009`009brw`009getp_out`009`009; and return
X;
Xerr:
X`009`009pushl`009r0`009`009`009; Pass error code 
X`009`009calls`009#1,g^lib$signal`009`009; Signal the error
X`009`009movl`009#1,r0`009`009`009; Set true condition for return
Xgetp_out:
X`009`009ret`009`009`009`009; Return to caller
X                .end
$ GoSub Convert_File
$ File_is="MACRO.MAR"
$ Check_Sum_is=806377209
$ Copy SYS$Input VMS_SHAR_DUMMY.DUMMY
X`009.macro`009$struct
Xprev_curprio=0
Xprev_baseprio=4
Xprev_cputim=8
Xprev_pid=12
Xprev_cpuused=16
Xprev_state=20
Xprev_proc=24
Xprev_imagecnt=28
Xprev_downcnt=32
Xprev_idlecnt=36
Xprev_strategy=40
Xprev_bias=44
Xprev_username=48
Xprev_newimage=62
Xprev_adj=66
Xprev_hog=70
Xprev_used=74
Xprev_upd=78
X`009.endm
$ GoSub Convert_File
$ File_is="MAKE.COM"
$ Check_Sum_is=1275191174
$ Copy SYS$Input VMS_SHAR_DUMMY.DUMMY
X$ makeit="@[-.exe]makeit"
X$ do="@[-.exe]do"
X$!
X$!
X$!
X$ if f$search("macro.mlb") .nes. "" then goto got_lib
X$ do lib/macro/create macro
X$ do lib/macro/insert macro macro
X$ got_lib:
X$ for_flags="/extend_source/nolist"
X$ mac_flags="/nolist"
X$ incs="params.inc,struct.inc,gdata.inc"
X$ if p1 .nes. "" then goto 'p1'
X$ sched:
X$ makeit sched for fortran "''for_flags'''p2'" "''incs'"
X$ if $status .eq. 3 then goto done
X$ makeit getproc mar macro "''mac_flags'''p3'"
X$ if $status .eq. 3 then goto done
X$ makeit gdata mar macro "''mac_flags'''p3'"
X$ if $status .eq. 3 then goto done
X$ makeit sleep mar macro "''mac_flags'''p3'"
X$ if $status .eq. 3 then goto done
X$ makeit mbx mar macro "+macro/lib''mac_flags'''p3'" "struct.mar"
X$ if $status .eq. 3 then goto done
X$ makeit sched_err msg message /nolist
X$ if $status .eq. 3 then goto done
X$ set noon
X$ sched/stop
X$ mcr install
Xsched$root:[exe]sched$gdata/delete
X$ set on
V$ makeit gdata gdata link "_share.opt/opt/share=[exe]sched$gdata.exe" "" "" ""
X -
X        "[EXE]SCHED$GDATA.EXE" 
X$ if $status .eq. 3 then goto done
X$ set noon
X$ mcr install
Xsched$root:[exe]sched$gdata/open/share/write
X$ set on
X$ makeit sched,sched_err,sleep,getproc,mbx sched link ",gdata.opt/opt''p4'" -
X    "[exe]sched$gdata.exe,gdata.opt" "" "[EXE]SCHED.EXE" "[EXE]SCHED.EXE"
X$ if $status .eq. 3 then goto done
X$!
X$!
X$!
X$ done:
X$ exit
X$!
X$!
X$!
X$ cmd:
X$ smgincs="params.inc,struct.inc,gdata.inc,smgdef.txt"
X$!
X$ makeit schcmd for fortran "''for_flags'''p2'" "''incs',smgdef.txt"
X$ if $status .eq. 3 then goto done
X$ list = ""
X$ hlist = ""
X$ makeit [.smg]begin_data for fortran "''for_flags'''p2'" "''smgincs'" -
X`009"" "begin_data.obj" 
X$ if $status .eq. 3 then goto done
X$ if $status .eq. 1 then -
X     list = list + "begin_data,"
X$ hlist = hlist + "begin_data,"
X$ makeit [.smg]blength for fortran "''for_flags'''p2'" "''smgincs'" -
X`009"" "blength.obj" 
X$ if $status .eq. 3 then goto done
X$ if $status .eq. 1 then -
X     list = list + "blength,"
X$ hlist = hlist + "blength,"
X$ makeit [.smg]end_display for fortran "''for_flags'''p2'" "''smgincs'" -
X`009"" "end_display.obj" 
X$ if $status .eq. 3 then goto done
X$ if $status .eq. 1 then -
X     list = list + "end_display,"
X$ hlist = hlist + "end_display,"
X$ makeit [.smg]end_smg for fortran "''for_flags'''p2'" "''smgincs'" -
X`009"" "end_smg.obj" 
X$ if $status .eq. 3 then goto done
X$ if $status .eq. 1 then -
X     list = list + "end_smg,"
X$ hlist = hlist + "end_smg,"
X$ makeit [.smg]init_display for fortran "''for_flags'''p2'" -
X`009"''smgincs',gdata.mar" "" "init_display.obj" 
X$ if $status .eq. 3 then goto done
X$ if $status .eq. 1 then -
X     list = list + "init_display,"
X$ hlist = hlist + "init_display,"
X$ makeit [.smg]put_data for fortran "''for_flags'''p2'" -
X`009"''smgincs',gdata.mar" "" "put_data.obj" 
X$ if $status .eq. 3 then goto done
X$ if $status .eq. 1 then -
X     list = list + "put_data,"
X$ hlist = hlist + "put_data,"
X$ makeit [.smg]put_queue for fortran "''for_flags'''p2'" -
X`009"''smgincs',gdata.mar" "" "put_queue.obj" 
X$ if $status .eq. 3 then goto done
X$ if $status .eq. 1 then -
X     list = list + "put_queue,"
X$ hlist = hlist + "put_queue,"
X$ makeit [.smg]reset_display for fortran "''for_flags'''p2'" -
X`009"''smgincs',gdata.mar" "" "reset_display.obj" 
X$ if $status .eq. 3 then goto done
X$ if $status .eq. 1 then -
X     list = list + "reset_display,"
X$ hlist = hlist + "reset_display,"
X$ makeit [.smg]smg_start for fortran "''for_flags'''p2'" "''smgincs'" -
X`009"" "smg_start.obj" 
X$ if $status .eq. 3 then goto done
X$ if $status .eq. 1 then -
X     list = list + "smg_start,"
X$ hlist = hlist + "smg_start,"
X$!
X$ if f$search ("smg.olb") .nes. "" then goto lib_exists
X$`009do library/create/object smg
X$`009list = hlist
X$ lib_exists:
X$ list = f$extract (0, f$length(list)-1, list)
X$ if list .nes. "" then do library/replace/object smg 'list'
X$ if list .nes. "" then create lib.
X$!
X$! makeit smg for fortran "''for_flags'''p2'" "''incs',smgdef.txt"
X$! if $status .eq. 3 then goto done
X$ makeit sched_err msg message /nolist
X$ if $status .eq. 3 then goto done
X$ makeit sleep mar macro "''mac_flags'''p3'"
X$ if $status .eq. 3 then goto done
V$ makeit schcmd,sched_err,sleep schcmd link ",gdata.opt/opt,smg/lib/notrace''p
X4'" -
V    "[exe]sched$gdata.exe,gdata.opt,smg.olb,lib." "" "[EXE]SCHCMD" "[EXE]SCHCM
XD"
X$ if $status .eq. 3 then goto done
X$ set noon
X$ mcr install
Xsched$root:[exe]schcmd/delete
Xsched$root:[exe]schcmd/priv=bypass
X$ set on
X$ goto done
X$!
X$!
X$!
X$ noimage:
X$ mcr install
Xsched$root:[exe]sched$gdata/delete
Xsched$root:[exe]schcmd/delete
X$ goto done
X$!
X$!
X$!
X$ image:
X$ mcr install
Xsched$root:[exe]sched$gdata/open/share/write
Xsched$root:[exe]schcmd/priv=bypass
X$ goto done
$ GoSub Convert_File
$ File_is="MBX.MAR"
$ Check_Sum_is=1981036361
$ Copy SYS$Input VMS_SHAR_DUMMY.DUMMY
V;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
X;
X;
X;`009Written by Gregg Wonderly,  Apr-10-1987
X;`009Department of Mathematics
X;`009Oklahoma State University
X;
X;
X;`009The routines in this file are associated with the use of the permanent
X;`009mailbox that is used to communicate with the scheduler.  The routines
X;`009here are the sole manipulators of the mailbox.  They create it, read
X;`009data from it, and delete it.
X;
X;`009All command dispatching for commands received via the mailbox is done
X;`009from here.
X;
V;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
X;
X;
X`009`009$ssdef
X`009`009$struct
X`009`009.psect`009data,rd,wrt,noexe
X
Xlen:
X`009`009.long`0090
Xmbxname:
X`009`009.ascid`009/SCHED$MBX/
Xast_ok:
X`009`009.long`0090
Xiochan:
X`009`009.long`0090
Xiosb:
X`009`009.quad`0090
Xbuffaddr:
X`009`009.blkb`009512
Xbuffsize=.-buffaddr
Xstrdescr:
X                .long   0
X                .long   0
X;
X;`009Commands currently recognized.  The format of a command is variable
X;`009except for the first 4 bytes which allways contains one of these values.
X;
XSNP$CHANGE_PRIORITY=1
XSNP$CHANGE_UP_PRIORITY=2
XSNP$CHANGE_DOWN_PRIORITY=3
XSNP$QUEUE_WATCH=4
XSNP$QUEUE_RELEASE=5
XSNP$SET_STRATEGY=6
X;
X`009`009.psect code,exe,rd,nowrt
X;
X;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
X;
X;`009Create a permanent mailbox to receive command from.
X;
X;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
X;
X`009`009.entry`009get_mbx,^m<r2,r3,r4>
X`009`009$crembx_s -`009`009`009;Create a mailbox
X`009`009`009prmflg=#1,-
X`009`009`009chan=iochan,-
X`009`009`009maxmsg=#buffsize,-
X`009`009`009bufquo=#512,-
X`009`009`009promsk=8(ap),-
X`009`009`009lognam=mbxname
X
X`009`009blbs`009r0,10$`009`009`009;Jump if all is well
X`009`009brw`009getmbx_err`009`009;Oops punt
X;
X10$:
X`009`009movl`0094(ap),r0`009`009;Get the address of the channel
X`009`009cvtwl`009iochan,(r0)`009`009;and store the result there
X`009`009movl`009#SS$_NORMAL,r0`009`009;Return normal completion
X`009`009brb`009getmbx_out`009`009;Exit
X;
Xgetmbx_err:
X`009`009pushl`009r0`009`009`009;Signal the error
X`009`009calls`009#1,g^lib$signal
X`009`009clrl`009r0`009`009`009;Return abnormal completion
Xgetmbx_out:
X`009`009ret`009`009`009`009;Return to caller
X;
X;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
X;
X;`009This routine can be called to perform a syncronous read on the
X;`009mailbox used to receive some commands.  This routine is also
X;`009called at AST level when unsolicited reads are enabled on the
X;`009mailbox.
X;
X;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
X;
X`009`009.entry`009readdone,^m<r2,r3,r4,r5,r6>
X
X`009`009moval`009g^gdata,r5`009`009; Get the global data address
X;
X;`009Read a command from the mailbox
X;
X`009`009$qiow_s`009-
X`009`009`009chan=iochan,-
X`009`009`009p1=buffaddr,-
X`009`009`009p2=#buffsize,-
X`009`009`009iosb=iosb,-
X`009`009`009func=#IO$_READVBLK!IO$M_NOW
X
X`009`009blbs`009r0,15$`009`009`009; Branch if no error
X`009`009cmpl`009r0,#SS$_ENDOFFILE`009; Check for EOF
X`009`009bneq`0095$`009`009`009; Go if not
X`009`009brw`00929$`009`009`009; Skip out
X5$:
X`009`009pushl`009r0`009`009`009; Signal the error
X`009`009movl`009r0,r3
X`009`009calls`009#1,g^lib$signal
X`009`009movl`009r3,r0`009`009`009; and return it
X`009`009brw`00940$
X;
X15$:
X`009`009cvtwl`009iosb,r1`009`009`009; Check the completion status
X`009`009blbs`009r1,17$`009`009`009; Jump if OK
X`009`009cmpl`009#SS$_ENDOFFILE,r1`009; Check for EOF
X`009`009bneq`00916$`009`009`009; Jump if not
X`009`009movl`009#RMS$_EOF,r0`009`009; Return EOF
X`009`009brw`00929$
X16$:
X`009`009pushl`009r1`009`009`009; Signal the error
X`009`009calls`009#1,g^lib$signal
X17$:
X`009`009cvtwl`009iosb+2,r0`009`009;Get the length
X`009`009cmpl`009r0,#4`009`009`009;Check for enough bytes
X`009`009bgtr`00918$`009`009`009;Jump if enough
X171$:
X`009`009movl`009#RMS$_EOF,r0`009`009;Return EOF
X`009`009brw`00929$`009`009`009;skip request
X;
X18$:
X`009`009movl`009buffaddr,r1`009`009;Get the message number
X;
X`009`009cmpl`009r1,#SNP$QUEUE_WATCH`009;Watch queue?
X`009`009bneq`00919$`009`009`009;Branch if not
X
X`009`009cmpl`009r0,#31`009`009`009;enough data?
X`009`009bleq`009171$`009`009`009;Jump if not
X`009`009pushab`009buffaddr+4`009`009;Push address of MIN data
X`009`009pushab`009buffaddr+16`009`009;Push address of MAX data
X`009`009cvtbl`009buffaddr+28,len`009`009;Get length of queue name
X`009`009pushal`009len`009`009`009;Push address of length
X`009`009moval`009buffaddr+29,strdescr+4`009;Build a string descriptor
X`009`009movl`009len,strdescr
X`009`009pushab`009strdescr`009`009;Push string descriptor address
X`009`009calls`009#4,add_queue`009`009;Add or modify entry
X`009`009brw`00929$
X;
X19$:
X`009`009cmpl`009r1,#SNP$QUEUE_RELEASE`009;Release queue?
X`009`009bneq`00921$`009`009`009;Branch if not
X
X`009`009cvtbl`009buffaddr+4,len`009`009;Get length of queue name
X`009`009moval`009buffaddr+5,strdescr+4`009;Build descriptor
X`009`009movl`009len,strdescr
X`009`009pushal`009len`009`009`009;Push address of length
X`009`009pushab`009strdescr`009`009;Push address of descriptor
X`009`009calls`009#2,release_queue`009;Release queue if found
X`009`009brw`00929$
X21$:
X`009`009cmpl`009r1,#SNP$CHANGE_PRIORITY`009;Change this processes priority?
X`009`009bneq`00924$`009`009`009;Branch if not
X
X`009`009$setpri_s -
X`009`009`009pri=buffaddr+4`009`009;Set priority
X`009`009blbs`009r0,22$`009`009`009;Branch if no error
X`009`009pushl`009r0
X`009`009calls`009#1,g^lib$signal`009`009;Signal the error
X22$:
X`009`009brw`00929$
X24$:
X`009`009cmpl`009r1,#SNP$CHANGE_UP_PRIORITY`009;Change up priority?
X`009`009bneq`00928$`009`009`009;Jump if not
X
X`009`009calls`009#0,clear_all`009`009;UNadjust all processes before change
X`009`009movl`009buffaddr+4,up_prio(r5)`009;Set new UP priority
X`009`009brw`00929$
X28$:
X`009`009cmpl`009r1,#SNP$CHANGE_DOWN_PRIORITY`009;Change down priority?
X`009`009bneq`009281$`009`009`009;Jump if not
X
X`009`009calls`009#0,clear_all`009`009;UNadjust all processes before changing
X`009`009movl`009buffaddr+4,down_prio(r5)`009;Set new down priority
X`009`009brb`00929$
X;
X281$:
X`009`009cmpl    r1,#SNP$SET_STRATEGY    ;Change the scheduling algorithm
X`009`009bneq    30$                     ;of a specific process
X
X`009`009cmpl`009r0,#16
X`009`009bneq`00930$
X
X`009`009pushal  buffaddr+4
X`009`009calls   #1,find_proc            ;Get a prev structure address.
X`009`009tstl    r0
X`009`009beql    30$                     ;Jump if no such process.
X`009`009movl`009buffaddr+8,prev_strategy(r0)
X`009`009movl`009buffaddr+12,prev_bias(r0)
X`009`009brb`00929$
X29$:
X`009`009tstl`009ast_ok`009`009`009;Reenable unsolicited input?
X`009`009beql`00940$`009`009`009;Jump if not
X;
X`009`009$qiow_s`009-`009`009`009;Requeue the qio
X`009`009`009chan=iochan,-
X`009`009`009p1=readdone,-
X`009`009`009p2=#0,-
X`009`009`009p3=#0,-
X`009`009`009func=#IO$_SETMODE!IO$M_WRTATTN
X
X`009`009blbs`009r0,40$`009`009`009;Branch if OK
X`009`009pushl`009r0`009`009`009;Save status
X`009`009movl`009r0,r3
X`009`009calls`009#1,g^lib$signal`009`009;Signal error
X`009`009movl`009r3,r0
X`009`009brb`00940$`009`009`009;Exit
X;
X30$:
X`009`009pushl`009#SS$_BADPARAM-4`009`009;Issue WARNING message
X`009`009calls`009#1,g^lib$signal`009`009;about the bad value
X`009`009brb`00929$
X;
X40$:
X`009`009ret`009`009`009`009;Return to caller
X
X;
X;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
X;
X;`009This routine will requeue the AST completion of unsolicted writes
X;`009on the mailbox.
X;
X;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
X;
X`009`009.entry`009ast_enable,^m<>
X
X`009`009movl`009#1,ast_ok`009`009;Say AST's are now OK
X`009`009$qiow_s`009-`009`009`009;Enable them
X`009`009`009chan=iochan,-
X`009`009`009p1=readdone,-
X`009`009`009p2=#0,-
X`009`009`009p3=#0,-
X`009`009`009func=#IO$_SETMODE!IO$M_WRTATTN
X
X`009`009blbs`009r0,40$`009`009`009;Jump if OK
X`009`009pushl`009r0`009`009`009;Pass error code
X`009`009calls`009#1,g^lib$signal`009`009;Signal the error
X40$:
X`009`009ret`009`009`009`009;Back to caller
X;
X;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
X;
X;`009This routine will disable the AST completion of unsolicited writes
X;`009on the mailbox.
X;
X;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
X;
X`009`009.entry`009ast_disable,^m<>
X
X`009`009clrl`009ast_ok`009`009;Say ast's not OK
X
X`009`009$cancel_s -`009`009`009;Cancel the I/O request
X`009`009`009chan=iochan
X
X`009`009blbs`009r0,40$
X`009`009pushl`009r0
X`009`009calls`009#1,g^lib$signal
X40$:
X`009`009ret
X;
X;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
X;
X;`009This routine deletes the mailbox in use by the scheduler.
X;
X;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
X;
X`009`009.entry`009del_mbx,^m<r2,r3>
X
X`009`009movl`0094(ap),r3`009`009;Get the channel to delete from
X`009`009$assign_s -
X`009`009`009chan=(r3),-
X`009`009`009devnam=mbxname`009`009;Assign an I/O channel to dev
X`009`009blbc`009r0,20$
X;
X`009`009$delmbx_s -`009`009`009;Delete the mailbox on the chan
X`009`009`009chan=(r3)
X;
X`009`009movl`009r0,r2`009`009`009;Save exit code
X`009`009$dassgn_s -
X`009`009`009chan=(r3)`009`009;Deassign the I/O channel
X`009`009movl`009r2,r0`009`009`009;Get error code back
X20$:
X`009`009pushl`009r0`009`009`009;Signal completion code
X`009`009calls`009#1,g^lib$signal
X`009`009ret
X`009`009.end
$ GoSub Convert_File
$ File_is="PARAMS.INC"
$ Check_Sum_is=225009118
$ Copy SYS$Input VMS_SHAR_DUMMY.DUMMY
X
X*       MAX_PROCS and MAX_QUEUES are also defined in GDATA.INC
X
X        parameter MAX_PROCS = 50
X        parameter MAX_QUEUES = 10
X
X*       Maximum length of an image name (also in GETPROC.MAR).
X
X        parameter MAXIMAGE = 250
X
X        parameter DEBUG = .false.
X        parameter STATS = .false.
X
X        parameter DEFAULT_DOWNCNT = 3
X        parameter DEFAULT_INTERVAL = 7
X        parameter DEFAULT_UP_PRIO = 5
X        parameter DEFAULT_DOWN_PRIO = 4
X        parameter DEFAULT_MAX = 50
X        parameter DEFAULT_MIN = 10
X        parameter DEFAULT_IO_DIFFERENCE = 2
X        parameter DEFAULT_MIN_TIME = 2000
X        parameter DEFSYSGRP = 6
X        parameter DEFAULT_HOGCOUNT = -1
X        parameter DEFAULT_HOGPRIO = 4
X        parameter DEFAULT_IDLECNT = 3
X        parameter DEFAULT_MAXACTIVE = 0
X
X        parameter SCH$NOSTRAT = 1
X        parameter SCH$IGNORE = 2
X        parameter SCH$SMASH = 3
X        parameter SCH$RESTART = 4
X        parameter SCH$NEWIMAGE = 5
$ GoSub Convert_File
$ Goto Part2

