source: WorldVistAEHR/trunk/r/KERNEL-XU-A4A7-USC-XG-XLF-XNOA-XPD-XQ-XVIR-ZI-ZOSF-ZOSV-ZT-ZU-%Z-XIP--XQAB--XUC--XUR--ZIN--ZTED/_ZTM6.m@ 1073

Last change on this file since 1073 was 613, checked in by George Lilly, 15 years ago

initial load of WorldVistAEHR

File size: 3.4 KB
RevLine 
[613]1%ZTM6 ;SEA/RDS-TaskMan: Manager, Part 8 (Load Balancing) ;07/28/2005 16:14
2 ;;8.0;KERNEL;**23,118,127,136,355**;JUL 10, 1995;Build 9
3 ;
4BALANCE ;CHECK^%ZTM--determine whether cpu should wait for balance
5 ;Return ZTOVERLD =1 if need to wait, 0 to run
6 ;The TM with the largest value sets ^%ZTSCH("LOAD",value)=who^when
7 ;If your value is greater or equal then you run.
8 ;If your value is less you wait unless you set LOAD then you run.
9 L +^%ZTSCH("LOAD"):5 N X,ZTIME,ZTLEFT,ZTPREV
10 N $ES,$ET S $ET="Q:$ES>0 D ER^%ZTM6"
11 S ZTOVERLD=0,ZTPREV=+$O(^%ZTSCH("LOAD",0)),@("ZTLEFT="_%ZTPFLG("BAL"))
12 S ZTIME=$$H3($H),ZTOVERLD=$$COMPARE(%ZTPAIR,ZTLEFT,ZTPREV)
13 ;If we are RUNNING have other submanagers wait
14 I 'ZTOVERLD D
15 . S X="" F S X=$O(^%ZTSCH("LOADA",X)) Q:X="" S $P(^(X),"^")=1
16 . K ^%ZTSCH("LOAD") S ^("LOAD",ZTLEFT)=%ZTPAIR_"^"_ZTIME
17 ;Now set a value that is used by our %ZTMS to run/wait also
18 S ^%ZTSCH("LOADA",%ZTPAIR)=ZTOVERLD_"^"_ZTLEFT_"^"_ZTIME_"^"_$J
19 L -^%ZTSCH("LOAD")
20 Q
21 ;
22STOPWT() ;See if we should stop Balance wait
23 L +^%ZTSCH("LOAD"):0 Q:'$T 0 ;Keep waiting if can't get lock
24 N I,J S I="",J=1
25 F S I=$O(^%ZTSCH("LOADA",I)) Q:I="" I '^(I) S J=0
26 L -^%ZTSCH("LOAD")
27 Q J ;Return: stop waiting 1, keep waiting 0.
28 ;
29CHECK ;Called when job limit reached.
30 ;If not doing balancing, remove node and quit
31 N I,J I %ZTPFLG("BAL")="" K ^%ZTSCH("LOADA",%ZTPAIR) Q
32 L +^%ZTSCH("LOAD"):0 Q:'$T ;Get it next time
33 S I=$O(^%ZTSCH("LOAD",0)),J=$G(^%ZTSCH("LOADA",%ZTPAIR))
34 S I=$P(J,"^",2)<I,$P(^%ZTSCH("LOADA",%ZTPAIR),"^",1)=I
35 L -^%ZTSCH("LOAD")
36 Q
37 ;
38COMPARE(ID,ZTLEFT,ZTPREV) ;
39 ;BALANCE--compare our cpu capacity left to that of previous checker
40 ;input: cpu name, cpu capacity left, cpu capacity of previous checker
41 ;output: whether current cpu should wait, 0=run, 1=wait
42 N X
43 I ZTLEFT'<ZTPREV Q 0
44 S X=^%ZTSCH("LOAD",ZTPREV)
45 I $P(X,"^",2)+150<ZTIME Q 0
46 Q $P(X,"^")'[ID
47 ;
48ER ;Clean up if error
49 S $EC="",%ZTPFLG("BAL")="",ZTOVERLD=0 L -^%ZTSCH("LOAD")
50 Q
51 ;
52H3(%) ;Convert $H to seconds
53 Q 86400*%+$P(%,",",2)
54 ;
55VXD(BIAS) ;--algorithm for VAX DSM
56 ;Capacity Left=Available Jobs - Active Jobs - (4 * Compute Queue Length)
57 ;output: cpu capacity left+bias
58 N ZTJ,ZTL S ZTJ=$$VXDJOBS
59 S ZTL=$P(ZTJ,",")-$P(ZTJ,",",2)-(4*$P(ZTJ,",",3)) I ZTL<1 S ZTL=1
60 Q ZTL+$G(BIAS)
61 ;
62VXDJOBS() ;
63 ;VXD--gather job table information
64 ;output: sysgen max # jobs, current # jobs, current # computable jobs
65 N
66 D INIT^%VOLDEF I '%SMSTART Q ""
67 S ZTJOBSIZ=%JOBSIZ,ZTJOBTAB=%JOBTAB
68 S ZTMAX=%MAXPROC,(ZTCOMP,ZTCOUNT)=0
69 F ZTJOB=1:1:ZTMAX D
70 .S ZTADDR=ZTJOB*ZTJOBSIZ+ZTJOBTAB,ZTPID=$V(ZTADDR+20) D VXDJ1:ZTPID Q
71 Q ZTMAX_","_ZTCOUNT_","_ZTCOMP
72 ;
73VXDJ1 ;VXDJOBS--adjust # active and # computable based on current entry
74 S X="VXDJE",@^%ZOSF("TRAP")
75 S ZTNAME=$ZC(%GETJPI,ZTPID,"PRCNAM") Q:ZTNAME["Sub"
76 S ZTSTATE=$ZC(%GETJPI,ZTPID,"STATE")
77 S ZTCOUNT=ZTCOUNT+1
78 I ZTSTATE["COM"!(ZTSTATE["CUR") S ZTCOMP=ZTCOMP+1
79VXDJE S X="",@^%ZOSF("TRAP") Q
80 ;
81MSM4() ;Use MSMv4 LAT calcuation
82 N MAXJOB,CURJOB
83 S MAXJOB=$V($V(3,-5),-3,0),CURJOB=$V(168,-4,2)
84 Q MAXJOB-CURJOB*255\MAXJOB
85 ;
86CACHE1(%) ;Use available jobs
87 N CUR,MAX
88 Q $$AVJ^%ZOSV()+$G(%)
89 ;
90CACHE2(%COM,%LOG) ;Cache, Pull metric data
91 N TMP,$ET
92 S $ETRAP="S $ECODE="""" Q ZTPREV"
93 S %LOG=$G(%LOG,"VISTA$METRIC")
94 I $L($G(%COM)) S TMP=$ZF(-1,%COM)
95 Q $ZF("TRNLNM",%LOG)
96 ;
97RNDRBN() ;Round Robin
98 L +^%ZTSCH("RNDRBN"):1
99 N R S R=$G(^%ZTSCH("RNDRBN"))+2,^%ZTSCH("RNDRBN")=(R#512)
100 L -^%ZTSCH("RNDRBN")
101 Q
Note: See TracBrowser for help on using the repository browser.