Thread engine for MSX

by snout on 05-08-2006, 13:13
Topic: Development
Languages:

Marcel Delorme has sent us the complete source code to a thread engine for MSX he recently developed. The thread engine allows developers to create multiple threads running on the MSX simultaneously, which could be interesting for people developing a GUI/OS. The sources by itself are, of course, interesting material to have a look at and the package contains a small program as an example.

Relevant link: Thread engine for MSX

Comments (26)

By Jorito

Mr. Ambassadors (1762)

Jorito's picture

05-08-2006, 13:44

Great stuff!

(Marcel told me to type that Tongue)

By mth

Champion (488)

mth's picture

06-08-2006, 00:15

Threads are evil! Don't use them if you don't have to.

That said, if you really do need threads, it's very nice to have a threading library instead of having to implement them yourself.

By msd

Paragon (1376)

msd's picture

06-08-2006, 15:55

what's so evil about them? Afraid of it? Tongue

By Sonic_aka_T

Enlighted (4130)

Sonic_aka_T's picture

06-08-2006, 16:03

Perhaps we can use them in our filemanager? Smile

By Nautilus

Expert (74)

Nautilus's picture

06-08-2006, 17:21

Nice lib, but SymbOS already has almost everething any MSX user could dream. Wink

By BiFi

Enlighted (4348)

BiFi's picture

06-08-2006, 18:15

does SymbOS also have a DOS prompt capable of running MSX-DOS and MSX-DOS2 programs? Wink

By Sonic_aka_T

Enlighted (4130)

Sonic_aka_T's picture

07-08-2006, 00:26

Indeed, I think SymbOS is *great*, but it's a very long way from being 'everything you need'. It's still beta, under contruction, lacks a lot of apps, for the moment it's still closed for development, and it will always be limited by the maximum capacities of the CPC, which are well below those of the MSX system. Not at all critisism towards SymbOS, but like any program, even SymbOS has it's limits, moreso while it's still in early beta stage... Apart from that, there's the 17.332.587 DOS/DOS2 applications BiFi mentioned which you won't be able to run from SymbOS... Anyhow; SymbOS: g00d! MSX-DOS2: also g00d...

By msd

Paragon (1376)

msd's picture

07-08-2006, 13:14

Running multiple com files at once would be quite hard to realize. The msx bios and bdos are not really thread save. I made a workaround for that.The schedular is disabled when a bdos function is called. However when you use blocking bdos calls (like _CIN) everything will come to a stand still.

By BiFi

Enlighted (4348)

BiFi's picture

07-08-2006, 15:18

The reason I gave for SymbOS also goes for WiOS (a GUI OS running on Gfx9000)... it got released and nothing happened. Reasons:

  • it is for Gfx9000
  • for decent speed a 7MHz MSX2(+) or MSXturboR is required
  • on MSX most developers are either assembly coders or Turbo Pascal (or the occasional BASIC) programmers, while WiOS was written in C
  • there is nothing to run existing MSX programs under WiOS

I know there were some people making things for WiOS which were demoed at a fair, but it didn't get any further than that. The only thing actually made and released for WiOS is a clock.

By MicroTech

Champion (384)

MicroTech's picture

07-08-2006, 16:25

@msd:
really cool, I like it.
Could be the first step toward vxWorks for Z80 Cool
I like the fact that your thread must not care about context switching, it can simply "go to sleep"
before its time-slice expires.

@BiFi:
I don't think WiOS was designed to run existing MSX applications 'cause they are too different.
In any case it's a pity WiOS "disappeard" Crying

By msd

Paragon (1376)

msd's picture

07-08-2006, 17:43

@microtech: Thanx.. vxWorks.. :-|
I'm now working on events for it. Which is very simple only need to add some extra management stuff for it and
WaitForSingleObject needs to check if it's a thread or event you are waiting for. Also the idea is to add
mapper support. Then you can really run a lot of threads Tongue

By Manuel

Ascended (16120)

Manuel's picture

08-08-2006, 08:49

BiFi: the Turbo Pascal thing is a bit weird, by the way, as it is just as easy to program in C for MSX as it is to programin Pascal.

By msd

Paragon (1376)

msd's picture

08-08-2006, 09:35

Wios doens't even have threads.. It's more a win3.1 like program Tongue

By anonymous

incognito ergo sum (109)

anonymous's picture

08-08-2006, 10:16

@msd: I sayed vxWorks 'cause we use it at work and IMHO it is an excellent example of multithread (real time) system.
I like this kind of operating system stuff and often I think it would be cool (and possible) to port some of vxWorks features to MSX.
It is scalable and with no graphical interface so, perhaps, there you could find extra-inspiration Wink

About mapper support: could I suggest you to insert in your code a "heap manager", a sort of memory (partition) handler so memory will be allocated (malloc?!) by a centralized entity.

About Wios: cooperative multitasking is better than no multitasking at all Tongue
IMHO WiOS is (was Crying) one of the most courageous attempts to upgrade/evolve MSX standard.

By msd

Paragon (1376)

msd's picture

08-08-2006, 10:32

Did think about memory management. Of course for segements I would just use the dos2 calls, but that's not enough

By MicroTech

Champion (384)

MicroTech's picture

08-08-2006, 10:46

I think MSX-C malloc can be easily modified to use extra parameters like heap start address, heap end address... in general each "partition" (you could read "segment") could have his own handle/handler.
Do you like C Question

By msd

Paragon (1376)

msd's picture

08-08-2006, 11:09

I code a lot in C/C++, but not on MSX.. Or atleast not so often. But a wrapper around the thread lib to use it in C would be doable.

By MicroTech

Champion (384)

MicroTech's picture

08-08-2006, 11:58

I use Ascii MSX-C and, in my project(s), I (already) mix C/M80/L80 compiled code with .com files compiled with other products, maybe I can be of any help Wink

By wolf_

Ambassador_ (9794)

wolf_'s picture

08-08-2006, 12:43

By on August 08 2006, 10:16

Question

By MicroTech

Champion (384)

MicroTech's picture

08-08-2006, 12:50

BTW: Wolf_ did you receive my e-mail I sent you on July 31 2006?

By ro

Guardian (4153)

ro's picture

08-08-2006, 12:55

Adding Memory Management sound like an OS already (atleast the foundations)
For public use, it's not interesting. So why bother. Else I've got all that ready on HD, in a OS foundation called MIDAS.

Threads? who needs them, or atleast WHY and WHERE?
To run multiple instances of a DOS program? or what?!?

Certainly not usable in demos,games and other stuff where, atleast, ints are used for timing critical layers.

Dunno, but the "news" section of MRC is getting more filthy with nonsence stuff. What's the value of "new BGM for SM2" as a newspost? Or this one? Com'on. Next I'll submit some news fact about new GFX I made for a new Game which prolly won't see the light ever. but who cares, it's NEWS.... bleeh

(sorry duded... I'm just overreacting I guess)

By ro

Guardian (4153)

ro's picture

08-08-2006, 12:56

overstimulation numbs me....

By AuroraMSX

Paragon (1901)

AuroraMSX's picture

08-08-2006, 13:06

/me still'd like to know why mth thinks threads are evil Smile

By msd

Paragon (1376)

msd's picture

08-08-2006, 13:29

Thread engine no news .. tss ro.. Anyway It's more prove of concept. I myself haven't made any application yet. besides a test program. We where thinking about a program which copies files on the background and lets you browse the HDD during it.
You can only use this to make a com with multiple threads. The educational value is probably higher than the practicle use of it, but maybe somebody can think of something nice to do with it.

By wolf_

Ambassador_ (9794)

wolf_'s picture

08-08-2006, 13:53

microtech.. yes, sorry, didn't have time to check it out yet.. I'm a bit busy these days, have to finish a short movie, prepare a commercial and install a new PC. Will try to check it out one of these days..

By msd

Paragon (1376)

msd's picture

11-08-2006, 11:09

@MicroTech: Feel free to built a C wrapper around it. Shoudn't be that hard.