[daip] total incomprehension of TVDEVS.SH
Patrick P. Murphy
pmurphy at NRAO.EDU
Tue Jul 24 12:06:25 EDT 2001
Though I'm no longer strictly in the AIPS group, I'll answer this one as I
probably wrote some/most of this code. Yes, it's a real mess, and
"crufty" is a fitting adjective. I think both Mark C. and I would roll
our eyes if we had to sit down and rewrite this mess...
On Mon, 16 Jul 2001 10:05:29 +1000 (EST), Vincent McIntyre
<Vince.McIntyre at atnf.CSIRO.AU> said:
> But when I start up with USEUNIXSOCK=YES + NEWUNIXSOCK=NO, I seem to get
> collisions between the various TVSERVn and XASn; ie the startup script
> fails to do the obvious thing of finding a free number for a tvserv.
As we tend not to use this mode much, I'm not surprised. However, I see
references to AIPS99; if you're not running 31DEC00 or 31DEC01, you should
consider upgrading. Yes, I know that's a pain, but otherwise we're fixing
things twice and you're missing out on a bunch of bug fixes.
> This is related to the somewhat crufty-looking code that messes with the
> $tvn variable and overrides the first guess at TVDEV, TVLOK etc. As far
> as I can tell it doesn't really override things, because it never
> updates TVN.
Could be... but read on; I'm not so sure.
> Here's an example for a small network with three hosts (ie TVSERVS is
> 3). I've included the 'sh -x START_AIPS' output, with comments. The
> relevant TVSERVS.SH code is excerpted below.
> TVD= #TVD=""
> + [ = ] #if [ "$TVD" = "" ] ; then
> + [ = YES ] # [ "$DEBUG" = "YES" ]
> i=1
> + [ -s /local/AIPS99/STARTING_TV_NUMBER ]
> + [ 1 -lt 36 ] #why is the maximum 36?
Extended hex: 0-9A-Z. The encapsulation of the TV number in the /tmp (or
$TMPDIR) socket names relies on a single character.
> + EHEX 1
> ei=1
> + ls /tmp/XAS.1.warrum /tmp/LOK.1.warrum /tmp/TKS.1.warrum /tmp/MSS.1.warrum
> + head -1
> OTH=/tmp/LOK.1.warrum
> + [ /tmp/LOK.1.warrum = ] #ok, we found one socket. is number 2 free?
> + expr 1 + 1
> i=2
> + [ 2 -lt 36 ]
> + EHEX 2
> ei=2
> + ls /tmp/XAS.2.* /tmp/LOK.2.* /tmp/TKS.2.* /tmp/MSS.2.*
> + head -1
> OTH=
> + [ = ] #yup, it's free
> TVN=2
Here it sets TVN. Maybe it doesn't export it... but that doesn't matter
as it's only an intermediate variable used to set TVDEV and friends; see
below.
> + [ = YES ] #[ "$DEBUG" "YES" ]
> + break
> + REHEX 2
> + [ 2 -eq 0 ]
> + REHEX 2
> tvn=2 # this is the weird bit
> + expr 2 + 3 #
The code is:
tvn=`expr $tvn + $AIPSTVS`
and IIRC this is a bit of legacy philosophy; make sure the "real" INET
based TVs have unique "TV numbers" and ensure the UNIX socket based TV's
don't use the same numbers. This was very important when we had the TV
image catalogs in physical files.
> tvn=5 #
> + EHEX 5 #
> tvhex=5 #
> tvhex=05 #
> TVDEV=TVDEV05
> TKDEV=TKDEV05
> TTDEV=TTDEV05
> TVLOK=TVLOK05
> + eval TVDEV05=/tmp/XAS.2.warrum
> TVDEV05=/tmp/XAS.2.warrum
> + eval TTDEV05=/tmp/MSS.2.warrum
> TTDEV05=/tmp/MSS.2.warrum
> + eval TKDEV05=/tmp/TKS.2.warrum
> TKDEV05=/tmp/TKS.2.warrum
> + eval TVLOK05=/tmp/LOK.2.warrum
> TVLOK05=/tmp/LOK.2.warrum
> + eval export TVDEV05 TTDEV05 TKDEV05 TVLOK05
> + export TVDEV05 TTDEV05 TKDEV05 TVLOK05
> The thing I don't understand is the business of the tvn variable,
> particularly adding $AIPSTVS to it and defining TVDEV$tvhex.
See above for tvn, and as for defining the ??DEV$tvhex variables, these
are what the AIPS tasks (and AIPS.EXE itself) use to trace where "the" TV
is. The concept of a numbered TV is very deeply entrenched in the AIPS
infrastructure, and so it always goes through the double environment
variable lookup (TVDEV -> TVDEVnn -> socket or device).
> The latter seems never to be reused later on in TVDEVS.SH, nor in
> START_AIPS, nor START_TVSERVERS.
But the getenv(getenv("TVDEV")) or equivalent is used, in AIPS Fortran
and/or C code. Extensively. In AIPS, its tasks, and XAS and friends.
> In UNIXSERVERS it is only tested that
> [ "$TVDEV" != "TVDEV00" ]
That's a catchall; TVDEV00 means "no tv".
The main function of TVDEVS.SH is to define those four sets of variables:
TVDEV for the XAS TV or image display, TTDEV for the message server, TKDEV
for the tek (graphics) server, and TVLOK for the TVSERV TV lock daemon.
> #2001-07-03 VJM this is a bug for > 9 tvs; compares HEX to DEC
Yup; thanks for finding that out!
Hope this illuminates things a bit.
- Pat
--
Patrick P. Murphy, Ph.D. Division Head, CV Computing, NRAO
Home: http://www.chien-noir.com/ Work: http://www.cv.nrao.edu/~pmurphy/
Spam poison: Argos at backspacedk.com borax at porkerl.gov nead at glaresg.edu
"Linux is Inevitable." "Why?" "Because it's alive!" - John MadDog Hall
More information about the Daip
mailing list