29 June 2018, 10:27 | #1 |
Registered User
Join Date: Mar 2018
Location: Prague
Posts: 35
|
Disk I/O vs. own multithreading routines
I've been thinking of writing my own simple multithreading system for A500 but still use Amiga's own file system routines to handle disk reading/writing. Is this possible to do or will I run into serious issues?
My main concern is that as far as I understand, you have to have the operating system up and running in the background to be able to use the disk handling routines. This will no doubt keep the multithreading routines up and running as well. Doesn't it? So they will interfere with my attempts to implement my own multithreading. How should I approach this issue or should I just forget it completely and spend my time doing something more useful? |
29 June 2018, 10:29 | #2 |
Total Chaos forever!
Join Date: Aug 2007
Location: Waterville, MN, USA
Age: 49
Posts: 2,186
|
AmigaOS uses non-blocking I/O. Is that what you're asking?
|
29 June 2018, 10:40 | #3 |
son of 68k
Join Date: Nov 2007
Location: Lyon / France
Age: 51
Posts: 5,323
|
There will (probably) be no problem if you can arrange so that your system is seen as single-threaded by the host OS, or, at least, you use always the same thread for i/o and never preempt tasks that don't belong to your program.
But, why wanting to implement your own multithreading and not reuse what's already there ? How to approach this issue may well depend on what exactly you want to achieve. I don't think it can be only academic, there is no single way of doing. |
29 June 2018, 17:30 | #4 |
Registered User
Join Date: Mar 2018
Location: Prague
Posts: 35
|
What I'm ultimately trying to do is test if it's viable option to have two threads for a game:
1. Realtime thread that runs the critical stuff (moving sprites etc.). When this thread is done it calls the thread #2. I.e. rest of the unused frame is given to non-realtime threads. 2. This contains stuff that can take multiple frames to process. When the current 50 FPS frame is over, the system automatically switches back to thread #1, no matter what this thread was currently doing. |
29 June 2018, 17:51 | #5 |
son of 68k
Join Date: Nov 2007
Location: Lyon / France
Age: 51
Posts: 5,323
|
That's pretty easy to do.
Just create thread #2 that has a lower priority than thread #1. Thus, as long as thread #1 is busy, thread #2 will not get any cpu time. Another way is to do the work of thread #1 in the vertical blank interrupt. |
29 June 2018, 18:03 | #6 |
Registered User
Join Date: Mar 2018
Location: Prague
Posts: 35
|
Ah so Amiga's own multithreading is actually fast enough to be usable at 50 FPS games?
And the vertical blank interrupt is a nice idea. Didn't think of that for some reason |
29 June 2018, 18:35 | #7 | |
son of 68k
Join Date: Nov 2007
Location: Lyon / France
Age: 51
Posts: 5,323
|
Quote:
Beware of disk i/o though. Only Dos processes can do that, not Exec tasks. For this reason the vblank might be a better option for you (assuming it's thread #2 that would have done the i/o part, if any) |
|
29 June 2018, 20:05 | #8 |
Registered User
Join Date: Mar 2018
Location: Prague
Posts: 35
|
I guess I'll go with the vblank interrupt then. Thanks!
|
29 June 2018, 21:31 | #9 |
Registered User
Join Date: May 2013
Location: Grimstad / Norway
Posts: 839
|
Commodore had some nice library or something other that gave you async versions of the mostly used DOS routines. I can't remember from where, but the CATS archives should include it.
|
30 June 2018, 10:31 | #10 |
Total Chaos forever!
Join Date: Aug 2007
Location: Waterville, MN, USA
Age: 49
Posts: 2,186
|
|
01 July 2018, 09:58 | #11 |
Registered User
Join Date: Mar 2018
Location: Prague
Posts: 35
|
Awesome, thanks!
If I use that ASyncIO library, can I use threads so that the disk IO happens somewhere else than in DOS process? Last edited by Crank; 01 July 2018 at 10:04. |
01 July 2018, 10:19 | #12 |
Total Chaos forever!
Join Date: Aug 2007
Location: Waterville, MN, USA
Age: 49
Posts: 2,186
|
Since AmigaOS doesn't use an MMU for memory protection while multitasking, a DOS process practically is a thread.
|
01 July 2018, 10:31 | #13 |
Registered User
Join Date: Mar 2018
Location: Prague
Posts: 35
|
OK, so this means I don't have to use the vblank interrupt trick then, but I can use system's own thread system. One thread handles all realtime stuff and one does the slower stuff, including the disk IO. Or maybe it's a good idea to have the disk related stuff in it's own thread and the two slower threads would be called in round robin style. Dunno yet. We'll see what happens.
|
01 July 2018, 10:35 | #14 |
Total Chaos forever!
Join Date: Aug 2007
Location: Waterville, MN, USA
Age: 49
Posts: 2,186
|
Read the documentation of the library first. Second, look at example code.
Last edited by Samurai_Crow; 01 July 2018 at 10:42. Reason: Bad syntax |
01 July 2018, 10:39 | #15 |
Registered User
Join Date: Mar 2018
Location: Prague
Posts: 35
|
Ok!
|
01 July 2018, 12:00 | #16 |
Registered User
Join Date: Mar 2018
Location: Prague
Posts: 35
|
Hmm, insteresting. I seem to have something unconfigured in my vbcc tools. When I write:
#include <dos/dos.h> The compiler complains: file 'dos/dos.h' not found The following: #include <devices/conunit.h> Gives the following long error: ----------------------------- > UBYTE warning 56 in line 17 of "exec/nodes.h": } expected included from file "/opt/vbcc/NDK_1.3/Includes1.3/include.h//exec/ports.h":14 included from file "/opt/vbcc/NDK_1.3/Includes1.3/include.h//devices/conunit.h":14 included from file "test.c":4 > UBYTE ln_Type; warning 54 in line 17 of "exec/nodes.h": ; expected included from file "/opt/vbcc/NDK_1.3/Includes1.3/include.h//exec/ports.h":14 included from file "/opt/vbcc/NDK_1.3/Includes1.3/include.h//devices/conunit.h":14 included from file "test.c":4 > UBYTE ln_Type; warning 67 in line 17 of "exec/nodes.h": type defaults to int included from file "/opt/vbcc/NDK_1.3/Includes1.3/include.h//exec/ports.h":14 included from file "/opt/vbcc/NDK_1.3/Includes1.3/include.h//devices/conunit.h":14 included from file "test.c":4 > UBYTE ln_Type; warning 125 in line 17 of "exec/nodes.h": no declaration-specifier, used int included from file "/opt/vbcc/NDK_1.3/Includes1.3/include.h//exec/ports.h":14 included from file "/opt/vbcc/NDK_1.3/Includes1.3/include.h//devices/conunit.h":14 included from file "test.c":4 > BYTE warning 67 in line 18 of "exec/nodes.h": type defaults to int included from file "/opt/vbcc/NDK_1.3/Includes1.3/include.h//exec/ports.h":14 included from file "/opt/vbcc/NDK_1.3/Includes1.3/include.h//devices/conunit.h":14 included from file "test.c":4 > BYTE ln_Pri; warning 125 in line 18 of "exec/nodes.h": no declaration-specifier, used int included from file "/opt/vbcc/NDK_1.3/Includes1.3/include.h//exec/ports.h":14 included from file "/opt/vbcc/NDK_1.3/Includes1.3/include.h//devices/conunit.h":14 included from file "test.c":4 > BYTE ln_Pri; warning 54 in line 18 of "exec/nodes.h": ; expected included from file "/opt/vbcc/NDK_1.3/Includes1.3/include.h//exec/ports.h":14 included from file "/opt/vbcc/NDK_1.3/Includes1.3/include.h//devices/conunit.h":14 included from file "test.c":4 > BYTE ln_Pri; warning 67 in line 18 of "exec/nodes.h": type defaults to int included from file "/opt/vbcc/NDK_1.3/Includes1.3/include.h//exec/ports.h":14 included from file "/opt/vbcc/NDK_1.3/Includes1.3/include.h//devices/conunit.h":14 included from file "test.c":4 > BYTE ln_Pri; warning 125 in line 18 of "exec/nodes.h": no declaration-specifier, used int included from file "/opt/vbcc/NDK_1.3/Includes1.3/include.h//exec/ports.h":14 included from file "/opt/vbcc/NDK_1.3/Includes1.3/include.h//devices/conunit.h":14 included from file "test.c":4 >} error 0 in line 20 of "exec/nodes.h": declaration expected included from file "/opt/vbcc/NDK_1.3/Includes1.3/include.h//exec/ports.h":14 included from file "/opt/vbcc/NDK_1.3/Includes1.3/include.h//devices/conunit.h":14 included from file "test.c":4 aborting... 1 error found! ----------------------------- Intuition and proto/exec.h includes work just fine. What am I missing? |
01 July 2018, 12:09 | #17 |
Registered User
Join Date: Mar 2018
Location: Prague
Posts: 35
|
Hmm, I can't seem to find any subfolder/file combo called "dos/dos.h" anywhere from under the following locations:
/opt/vbcc/NDK_1.3/Includes1.3/include.h /opt/vbcc/NDK_1.3/Include-Strip1.3/include.h /opt/vbcc/targets/m68k-kick13/include |
01 July 2018, 12:53 | #18 |
Total Chaos forever!
Join Date: Aug 2007
Location: Waterville, MN, USA
Age: 49
Posts: 2,186
|
I'm pretty sure that AsyncIO needs Kickstart 2 but I could be wrong. Also you need the system includes that don't always come with VBCC.
Look on http://amigadev.elowar.com for system includes and documentation. Last edited by Samurai_Crow; 01 July 2018 at 12:58. |
01 July 2018, 13:53 | #19 |
Registered User
Join Date: Mar 2018
Location: Prague
Posts: 35
|
This seems to be harder to get up and running than I thought:
The only place I can find the actual header files from (not in document format but as .h files) seems to be the commercial Amiga Developer CD which would need to be ordered online. I also don't own CD/DVD drive in any of my computers. What other options do I have to find the proper files? EDIT: dos.h seems to be includable from "proto/dos.h" and from "libraries/dos.h" |
01 July 2018, 16:39 | #20 |
Total Chaos forever!
Join Date: Aug 2007
Location: Waterville, MN, USA
Age: 49
Posts: 2,186
|
Since you appear to be using a Linux hosted cross compiler, try Bebbo's GCC 6.4 compiler. It downloads the AmigaOS 3.9 NDK from the Haage and Partner website with a makefile target.
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Using DOS routines after a system take over | majikeyric | Coders. General | 45 | 23 July 2023 10:11 |
Help with CanDo routines | fstltna | support.Apps | 2 | 10 March 2023 19:18 |
decompression routines | Toni Wilen | Coders. General | 12 | 17 May 2017 00:30 |
OSTER's assembler routines & tricks | Shoonay | Coders. Tutorials | 8 | 17 November 2016 15:41 |
Checksum routines in games | Joejoe | Coders. Tutorials | 11 | 26 December 2009 20:24 |
|
|