Page 1 of 1
Channels & Things
Posted: Wed Mar 26, 2025 7:37 am
by Giorgio Garabello
Do you know a way to find out (via Superbasic) which channels and things are used by a given job?
Basically to do what the QPAC2 channels menu does but via Superbasic.
Giorgio
Re: Channels & Things
Posted: Wed Mar 26, 2025 7:51 am
by tofro
You need to walk the channel table (SV_CHBAS points to it, SV_CHTOP points to its end, SV_CHMAX indicates the number of actually used entries) and each entry is a long pointer to a channel definition block. The long word at $8 of the channel definition block is the owner job ID.
Code: Select all
1000 SV_BAS =VER$(-2)
1010 PRINT "System Variables:",HEX$(SV_BAS,32)
1020 SV_CHBAS = PEEK_L(SV_BAS + $78) : sv_chmax = PEEK_W (SV_BAS + $72) : SV_CHTOP = PEEK_L(SV_BAS + $7C)
1030 numChannels = (SV_CHTOP - SV_CHBAS)/4
1040 PRINT "SV_CHBAS:", HEX$(SV_CHBAS, 32), "SV_CHTOP:", HEX$(SV_CHTOP, 32), "NumChannels:",sv_chmax
1050 :
1060 FOR i = SV_CHBAS TO SV_CHTOP STEP 4
1070 chNum = (i - SV_CHBAS) / 4
1080 IF chNum > sv_chmax : EXIT i
1090 CHDB = PEEK_L (i)
1100 chLen = PEEK_L (CHDB + 0)
1110 chDriver = PEEK_L (CHDB + 4)
1120 chOwner = PEEK_L (CHDB + 8)
1130 chTag = PEEK_L (CHDB + $10)
1140 PRINT "Channel:", chNum, "ID: ", HEX$(i,16) & HEX$(chTag, 16), "Owner:", HEX$(chOwner, 32)
1150 PAUSE(-1)
1160 END FOR i
Getting the file/device name for a channel ID is "a bit non-trivial" (i.e., a mystery to me) and needs peeking through system internals. I don't know of anything that documents this. TT as an application writer must have done what Microsoft was sued for decades later (using his system knowledge in applications)

Re: Channels & Things
Posted: Wed Mar 26, 2025 9:51 am
by Giorgio Garabello
Damn! I don't think I can understand anything.

First of all, thanks for your program! I'll archive it in my documentation.
Thanks
Re: Channels & Things
Posted: Wed Mar 26, 2025 4:52 pm
by tofro
Don't give up so fast!
It's actually quite easy:
SV_CHBASE (one entry in the system variables) holds the address of a table in memory that contains SV_CHMAX longwords.
Each of this longwords is the address of a channel definition block.
A channel definition block looks like that
Code: Select all
CH_LEN $00 long length of definition block
CH_DRIVR $04 long address of driver
CH_OWNER $08 long owner job
CH_RFLAG $0C long address to be set when space released
CH_TAG $10 word channel tag
CH_STAT $12 byte status - 0 OK, negative waiting
-1 A1 abs, $80 A1 rel A6
CH_ACTN $13 byte stored action for waiting job ID
CH_JOBWT $14 long of job waiting on IO
and describes the properties of this specific channel.
And the code above simply follows these pointers to retrieve CH_OWNER (the channel owner job ID) from these entries.
Re: Channels & Things
Posted: Thu Mar 27, 2025 7:04 am
by Giorgio Garabello
Thank you very much for your help, I will try to do some tests over the weekend