Using preemptive multitasking

Anything QL Software or Programming Related.
ecdhe
ROM Dongle
Posts: 15
Joined: Sat Jun 14, 2025 9:35 pm

Using preemptive multitasking

Post by ecdhe »

As QOS supports preemptive multitasking, I tried running two jobs in parallel. So I wrote two programs which constantly update resp. the left and right ends of the screen and try to call them using EXEC. Given it's preemptive multitasking, I assume (wrongly?) that I should not do anything special to my programs.

Using QOS 1.10, the EXEC command starts the first program successfully but does not return (contrary to what the doc says). It does support the JOBS command though, so would think it supports multitasking.
Using Minerva, EXEC does return and I can launch the two programs. However, typing JOBS just prints the header and hangs. JOBS works perfectly when only one program is running but when not two are.

Are there any specific things to know about multitasking on the QL? I did use SEXEC to generate the executables I'm running in parallel.


User avatar
Peter
Font of All Knowledge
Posts: 2461
Joined: Sat Jan 22, 2011 8:47 am

Re: Using preemptive multitasking

Post by Peter »

ecdhe wrote: Wed Jun 25, 2025 3:18 pm Using QOS 1.10, the EXEC command starts the first program successfully but does not return (contrary to what the doc says).
This means the machine code program you had saved with SEXEC is faulty.


ecdhe
ROM Dongle
Posts: 15
Joined: Sat Jun 14, 2025 9:35 pm

Re: Using preemptive multitasking

Post by ecdhe »

Fair enough, but are there any common caveats to look for? I made sure the program does not use any RAM for its data (only using registers), and only modifies the screen (which, based on some videos I've seen, seems acceptable).


ecdhe
ROM Dongle
Posts: 15
Joined: Sat Jun 14, 2025 9:35 pm

Re: Using preemptive multitasking

Post by ecdhe »

Hang on, I just though of something. I'll try later tonight. But thanks for confirming it should work with QOS 1.1


Derek_Stewart
Font of All Knowledge
Posts: 4779
Joined: Mon Dec 20, 2010 11:40 am
Location: Sunny Runcorn, Cheshire, UK

Re: Using preemptive multitasking

Post by Derek_Stewart »

Hi

The QL does support multitasking, but it doesn't support buried screen updates, which I mean updating a SCR or CON channel.

There are extensions to enable this called PICE,NICE which you may say, the programs running do not update the screen.

Use Minerva, as anything like JS, JM, has bugs on it and may not run programs as expected.

With regards to the SEXEC command, it needs amount of data to create the executable program correctly.


Regards, Derek
User avatar
RalfR
QL Wafer Drive
Posts: 1205
Joined: Fri Jun 15, 2018 8:58 pm

Re: Using preemptive multitasking

Post by RalfR »

If I understood him correctly, he means "the left and right ends of the screen," meaning that the windows don't overlap, right?

Perhaps a photo would be helpful.


7000 4E75
User avatar
dilwyn
Mr QL
Posts: 3126
Joined: Wed Dec 01, 2010 10:39 pm

Re: Using preemptive multitasking

Post by dilwyn »

Some information about writing Jobs in section 3 of this manual, including how to terminate a job properly:

https://dilwyn.theqlforum.com/docs/manuals/qltm.pdf


ecdhe
ROM Dongle
Posts: 15
Joined: Sat Jun 14, 2025 9:35 pm

Re: Using preemptive multitasking

Post by ecdhe »

By starting from a program which does nothing but which works and adding more code I was able to figure out what was wrong: the `trap #0` code (switch to superviser mode) doesn't mix well with the multitasking.

This works now and I have two programs running in parallel and I can change the priority of both jobs. Thank you to all those who replied!
Last edited by ecdhe on Wed Jun 25, 2025 10:58 pm, edited 1 time in total.


User avatar
Peter
Font of All Knowledge
Posts: 2461
Joined: Sat Jan 22, 2011 8:47 am

Re: Using preemptive multitasking

Post by Peter »

TRAP #0 enters supervisor mode. You should not use it, unless you really know what you are doing. A job needs to stay in user mode for normal scheduling.


ecdhe
ROM Dongle
Posts: 15
Joined: Sat Jun 14, 2025 9:35 pm

Re: Using preemptive multitasking

Post by ecdhe »

Peter wrote: Wed Jun 25, 2025 10:48 pm TRAP #0 enters supervisor mode. You should not use it, unless you really know what you are doing. A job needs to stay in user mode for normal scheduling.
Yes, I understand this. I used this code to to sync with the vblank. This works fine in a single-program case, but of course not in a multitasking environment. Just like RAM conflict can happen quite easily as the 6800X doesn't support protected mode.


Post Reply