Passing channels to jobs

Anything QL Software or Programming Related.
User avatar
NormanDunbar
Forum Moderator
Posts: 2274
Joined: Tue Dec 14, 2010 9:04 am
Location: Leeds, West Yorkshire, UK
Contact:

Re: Passing channels to jobs

Post by NormanDunbar »

He means do this:

Code: Select all

[code] 1000 Print x
[/code]

Or

Code: Select all

[code] 
1000 Print 'Hello Norm!'
2000 goto 1000
[/code]


To get code blocks in a posting.


Cheers,
Norm.


Why do they put lightning conductors on churches?
Author of Arduino Software Internals
Author of Arduino Interrupts

No longer on Twitter, find me on https://mastodon.scot/@NormanDunbar.
User avatar
pjw
QL Wafer Drive
Posts: 1313
Joined: Fri Jul 11, 2014 8:44 am
Location: Norway
Contact:

Re: Passing channels to jobs

Post by pjw »

Tinyfpga wrote:<>
Does via a toolkit mean via a Knoware toolkit. If so which might it be ? If not, can a general purpose toolkit be written?
The toolkit in question was included with the example I gave above, Test.zip. It is a kind of PRINT command, except it can take a real channel ID. The other command, CHANID simply converts a S*BASIC channel number to a channel ID. So job#1 (Master) passes its channel ID to job#2 (Slave) so job#2 can print to job#1's window.


Per
dont be happy. worry
- ?
Tinyfpga
Gold Card
Posts: 252
Joined: Thu Sep 27, 2018 1:59 am

Re: Passing channels to jobs

Post by Tinyfpga »

I downloaded pjw's Test.zip code and unziped it to ram1 in SMSQ/E. After a bit of faffing around I manged to EX (as interpret, I think) the two _bas programs
successfully. I can sort of see what is going on but I do not use the SMSQ/E interpreter so the programs are not in a form I am familiar with..

When I get the time I will try to work out what the code does and see If I can make use of the two new functions ( PRTSTR% and CHANID ) you so kindly provided.

As an aside; Why do Qlers use the SMSQ/E interpreter with line numbered code, rather than the freeform code I use with the QD/Qliberator combination?


User avatar
pjw
QL Wafer Drive
Posts: 1313
Joined: Fri Jul 11, 2014 8:44 am
Location: Norway
Contact:

Re: Passing channels to jobs

Post by pjw »

Tinyfpga wrote:I downloaded pjw's Test.zip code and unziped it to ram1 in SMSQ/E. After a bit of faffing around I manged to EX (as interpret, I think) the two _bas programs
successfully. I can sort of see what is going on but I do not use the SMSQ/E interpreter so the programs are not in a form I am familiar with..

When I get the time I will try to work out what the code does and see If I can make use of the two new functions ( PRTSTR% and CHANID ) you so kindly provided.

As an aside; Why do Qlers use the SMSQ/E interpreter with line numbered code, rather than the freeform code I use with the QD/Qliberator combination?
The reason the SBASIC code is line-numbered is so you can EXecute it directly. In the case in point, if both master_bas and slave_bas are in ram1_, all you have to do is EX ram1_master. master_bas needs to EXecute ram1_slave_bas by itself so it can send it its channelID in the command line.

EX in SBASIC is specially designed to recognise SBASIC programs and execute them in the interpreter, but if you have any structures in the code (multi-line IFs, SELects, REPeats, etc) you need line numbers (for some reason) unlike QD, which adds them on the fly.


Per
dont be happy. worry
- ?
User avatar
pjw
QL Wafer Drive
Posts: 1313
Joined: Fri Jul 11, 2014 8:44 am
Location: Norway
Contact:

Re: Passing channels to jobs

Post by pjw »

So heres another circus trick. Five slaves writing to their master's channel simultaneously:

Code: Select all

100 JOB_NAME 'Master'
110 ch = FOPEN("con"):           rem All slaves will write here
120 PAPER#ch; 7: CLS#ch
130 :
140 FOR n% = 1 TO 5:             rem 5 slaves is enough
150 cl$ = n% & HEX$(CHANID(#ch), 32): rem Command line
160  EX_M 'ram1_slave_bas'; cl$: rem Slave n%, owned by me
170  SUSJB -1, 0:                rem Reschedule
180 END FOR n%
190 SUSJB -1, 1200:              rem Wait for slaves to finish
200 QUIT

Code: Select all

100 COLOUR_24
110 :
120 cl$ = CMD$
130 y% = cl$(1):                 rem Slave number
140 ch = HEX(cl$(2 TO)):         rem Channel ID
150 :
160 JOB_NAME "slave " & y%
170 :
180 SPJOB -1, y% * 8:            rem Test different priorities..
190 :
200 SELect ON y%:                rem Each slave a different colour
210  = 1: col = $FF0000
220  = 2: col = $FF00
230  = 3: col = $FF
240  = 4: col = $FF00FF
250  = 5: col = $FFFF00
260 END SELect
270 :
280 t% = -1:                     rem Timeout
290 x% =  1:                     rem columnn 1
300 :
310 FOR i = 1 TO 999999:         rem Massive count
320  i$ = i & ' '
330  er% = PRTSTR%(#ch, t%! x%, y%\ col; i$)
340  IF er% < 0: EXIT i
350  SUSJB -1, 0:                rem Enter scheduler briefly
360 END FOR i
370 :
380 QUIT
Assumptions: SMSQ/E in hi color mode. LRESPR PSTEST_bin from the Test.zip example code given above, in SBASIC, job#0.
(For those who happen not to know: Click the Select All link above the code section and then press CTRL C. Switch to your emulator (QPC2 or SMSQmulator) and fire up QD. In QD press F2 A, followed by SPACE to copy the buffer there. Save the first code as ram1_master_bas. Repeat for the slave_bas code.)
In SBASIC EX ram1_master. You should see each slave, using its own colour, write to the window. You could verify that the five slaves are running, and that only one channel is being used.
There is an anomaly: Each slave doesnt only write on its designated line, but occasionally scribbles on the wrong x and y coordinates. This is because the calls within PRTSTR% are not atomic between setting the colour, the x/y position, and printing the string, so it gets interrupted mid-stream, as it where, by another slave. It would, of course be possible to fix that, but that never was the intention with PRTSTR%, which has just be coopted for the sake of the demonstration.
Anyway, yes, it sort of works to have multiple jobs writing to the same channel, but there are certain challenges. I doubt that any of this was intended, although it probably could be made to work it really wanted/needed. Fine for things like clocks and the like, though.


Per
dont be happy. worry
- ?
Tinyfpga
Gold Card
Posts: 252
Joined: Thu Sep 27, 2018 1:59 am

Re: Passing channels to jobs

Post by Tinyfpga »

Thank you pjw for your tips.

I was in the middle of posting (directly into the forum editor) some thoughts when my post just vanished, not to be found again. This time I am writing it in Wordpad so that it can't happen again.

Once I realised that your two code samples were designed to be interpreted, I placed them in two QDs, edited them, saved them and then EXed them in #0.
I normally write my code in freeform QD text then compile and execute in one operation by "pressing" a button in the
QD menu bar. I make many mistakes when writing code so I am constantly editing-executing-editing until I am happy with the results only then do I save the code to disk. I find that this is significantly faster than the edit-save-EX.file sequence required for interpretation.
I also find constrained line numbered code harder to read. I like the freedom to space/delineate my code with blanks and characters.

I have finally mastered the PrtSc key on my laptop. The sequence of events that have to performed to get a compressed
grey scale ( to match my Q68 display ) QPC screenshot was not obvious. Most of what Google told me did not work on my windows 7 laptop.

I have not yet succeeded in transferring QD text to PC to forum and back again without creating format errors but I am sure I will get there in the end. As for zipping and unzipping in SMSQ/E that is something yet to be fully understood.

Thank you once again for your patient tuition.


Tinyfpga
Gold Card
Posts: 252
Joined: Thu Sep 27, 2018 1:59 am

Re: Passing channels to jobs

Post by Tinyfpga »

pjw your latest code samples and very useful associated notes look very interesting. When I find the time I will be cheekily converting your (much easier to read now you have added some : and REMs) code, into the form I like for compiling.

As to your thoughts of this being useful, I would say it is for two reasons:

Firstly the main use of a Q68 at the moment is as a leisure activity. Removing a limit to writing multi tasking, and with networked Q68s, multi processing
applications is, for those of a certain predisposition, enjoyable.

Secondly for Stella ( you know;Tony Tebby's ultimate OS ) running in large multiprocessing/memory FPGAs arrays, this kind of thing will be essential.

All you have to do is convince Peter Graf, Marcel Kilgus, Wolfgang Lenerz et al. to see this future as a Quantum Leap. Then you really, will have a QL.


User avatar
pjw
QL Wafer Drive
Posts: 1313
Joined: Fri Jul 11, 2014 8:44 am
Location: Norway
Contact:

Re: Passing channels to jobs

Post by pjw »

Tinyfpga wrote:pjw your latest code samples and very useful associated notes look very interesting. When I find the time I will be cheekily converting your (much easier to read now you have added some : and REMs) code, into the form I like for compiling.
Right now I was fascinated to see how the slaves, all working at different priorities, incremented their numbers at different speeds! Ive never seen this so clearly before. Of course, one needs to use a better choice of colours than I used. Also, no reason to stop at 5 slaves.., Then just set the master to wait a bit more patiently for the slaves to finish their work..
As to your thoughts of this being useful, I would say it is for two reasons:

Firstly the main use of a Q68 at the moment is as a leisure activity. Removing a limit to writing multi tasking, and with networked Q68s, multi processing
applications is, for those of a certain predisposition, enjoyable.
Sure. Ive been waiting since I first heard Leon Heller (of QUANTA fame. Remember him?) talk of Transputers..
Secondly for Stella ( you know;Tony Tebby's ultimate OS ) running in large multiprocessing/memory FPGAs arrays, this kind of thing will be essential.
I doubt that will ever materialise now..
All you have to do is convince Peter Graf, Marcel Kilgus, Wolfgang Lenerz et al. to see this future as a Quantum Leap. Then you really, will have a QL.
After this week, I wouldnt dare to ask for any more for a good long while ;)


Per
dont be happy. worry
- ?
Tinyfpga
Gold Card
Posts: 252
Joined: Thu Sep 27, 2018 1:59 am

Re: Passing channels to jobs

Post by Tinyfpga »

pjw wrote:- After this week, I wouldn't dare to ask for any more for a good long while.

I have decided to take the risk that you are not referring to me so, here goes:-
Can one compile your sample code with Qliberator set to no-win?. I have tried and failed.


User avatar
pjw
QL Wafer Drive
Posts: 1313
Joined: Fri Jul 11, 2014 8:44 am
Location: Norway
Contact:

Re: Passing channels to jobs

Post by pjw »

Tinyfpga wrote:pjw wrote:- After this week, I wouldn't dare to ask for any more for a good long while.

I have decided to take the risk that you are not referring to me so, here goes:-
Can one compile your sample code with Qliberator set to no-win?. I have tried and failed.
Add the toolkit to line 10, remove the REM line at 200 (not Qlib compatible) and get rid of the inline hex. It compiles for me.
No point in compiling master_bas, just change its line from execute slave_bas to execute slave_obj instead, and then RUN it (or F10 it from SBAS/QD)

Code: Select all

10 REMark $$asmb=win1_prg_test_chn_PSTST_BIN,0,10
100 COLOUR_24
110 :
120 cl$ = CMD$
130 y% = cl$(1):                 REMark Slave number
140 ch = HEX(cl$(2 TO)):         REMark Channel ID
150 :
160 JOB_NAME "slave " & y%
170 :
180 SPJOB -1, y% * 8:            REMark Test different priorities..
190 :
200 SELect ON y%
210  = 1: col = HEX('F0000')
220  = 2: col = HEX('FF00')
230  = 3: col = 255
240  = 4: col = HEX('FF00FF')
250  = 5: col = 0
260 END SELect
270 :
280 t% = -1:                     REMark Timeout
290 x% =  1:                     REMark columnn 1
300 :
310 FOR i = 1 TO 999999:         REMark Massive count
320  i$ = i & ' '
330  er% = PRTSTR%(#ch, t%! x%, y%\ col; i$)
340  IF er% < 0: EXIT i
350  SUSJB -1, 0:                REMark Enter scheduler briefly
360 END FOR i
370 :
380 QUIT


Per
dont be happy. worry
- ?
Post Reply