BBC BASIC for Windows
« SYS"CreateThread" »

Welcome Guest. Please Login or Register.
Apr 5th, 2018, 9:49pm



ATTENTION MEMBERS: Conforums will be closing it doors and discontinuing its service on April 15, 2018.
Ad-Free has been deactivated. Outstanding Ad-Free credits will be reimbursed to respective payment methods.

If you require a dump of the post on your message board, please come to the support board and request it.


Thank you Conforums members.

BBC BASIC for Windows Resources
Online BBC BASIC for Windows documentation
BBC BASIC for Windows Beginners' Tutorial
BBC BASIC Home Page
BBC BASIC on Rosetta Code
BBC BASIC discussion group
BBC BASIC for Windows Programmers' Reference

« Previous Topic | Next Topic »
Pages: 1  Notify Send Topic Print
 thread  Author  Topic: SYS"CreateThread"  (Read 683 times)
Ric
Full Member
ImageImageImage


member is offline

Avatar




PM

Gender: Male
Posts: 136
xx SYS"CreateThread"
« Thread started on: Apr 17th, 2017, 6:31pm »

I have posed this question on the other forum, but it cant harm to ask here too,

Probably one for Richard, but does anyone know if it is possible to get 2 assembly routines to run truly in parallel? With maybe a shared memory location to trigger the routines. Say:


Routine 1
Do something
On result set !data=1
Repeat routine 1


Routine 2
Check !data
If 0 repeat routine 2
If 1 do something
Set !data=0
Repeat routine 2

Richard pointed me at winlib2 and winlib4 but if I'm honest I do not understand the coding in these demos. there are way to many SYYSTEM/API calls to take in and I don't know which ones are relevant to CreateThread.

I need something with far less variables for my tiny brain to get round or even better could someone supply just the basic code.

This is a simple pseudo code of what I would like to produce :-

SYS "CreateThread" assembly label1
SYS "CreateThread" assembly label2
SYS "CreateThread" assembly label3

etc...

From my BB4W program, leave the assembly running in the background with a few memory location changes to operate the assembly routines and then for them to terminate only when the BASIC program is terminated.

Regards Ric







User IP Logged

It's always possible, but not necessarily how you first thought. Chin up and try again.
Ric
Full Member
ImageImageImage


member is offline

Avatar




PM

Gender: Male
Posts: 136
xx Re: SYS"CreateThread"
« Reply #1 on: Apr 19th, 2017, 2:26pm »

Found a wonderful post by Michael Hutton which has answered all my questions and more, (Thanks Michael).

This is the result, it is not very well put together and doesn't error trap too well but have a go and see the speed difference between Series ASM and Threaded ASM. It really opens up the possibilities for graphics generation.

https://1drv.ms/u/s!AqibHqCkE1VQkGSysm8B0c6voOI9
Regards Ric
« Last Edit: Apr 20th, 2017, 08:32am by Ric » User IP Logged

It's always possible, but not necessarily how you first thought. Chin up and try again.
DDRM
Administrator
ImageImageImageImageImage


member is offline

Avatar




PM

Gender: Male
Posts: 321
xx Re: SYS"CreateThread"
« Reply #2 on: Apr 20th, 2017, 08:14am »

Hi Ric,

Thanks for posting some working code - I get almost a halving of the time, which is perhaps a bit disappointing on a quad-core machine where you have tried to grab 3 threads, but I suspect there's all sorts of junk using some of my cores...

BTW, your link misses the initial "htt", so it doesn't work when clicked - if you could amend it, that would be helpful! Or here it is...

https://1drv.ms/u/s!AqibHqCkE1VQkGSysm8B0c6voOI9

Best wishes,

D
User IP Logged

Ric
Full Member
ImageImageImage


member is offline

Avatar




PM

Gender: Male
Posts: 136
xx Re: SYS"CreateThread"
« Reply #3 on: Apr 20th, 2017, 08:35am »

Thanks D

I get the same results on my laptop, I have tried to change the number of frames rastered so the delay for setting up the thread is minimized, but still get the same result. I can only presume 2 threads is not twice as quick as 1.

PS changed link,

Regards Ric
User IP Logged

It's always possible, but not necessarily how you first thought. Chin up and try again.
Ric
Full Member
ImageImageImage


member is offline

Avatar




PM

Gender: Male
Posts: 136
xx Re: SYS"CreateThread"
« Reply #4 on: Apr 29th, 2017, 8:51pm »

Could someone with a slightly more powerful machine try this code and post the results back.

The code is threading in ASM, again it is not pretty with little error trapping, but it works smiley

https://1drv.ms/u/s!AqibHqCkE1VQkHgjdT7XQF5DYExJ

Good luck

Ric
User IP Logged

It's always possible, but not necessarily how you first thought. Chin up and try again.
DDRM
Administrator
ImageImageImageImageImage


member is offline

Avatar




PM

Gender: Male
Posts: 321
xx Re: SYS"CreateThread"
« Reply #5 on: May 2nd, 2017, 08:09am »

Hi Ric,

222 vs 478, on a quad core i5-based machine, if that helps.

Best wishes,

D
User IP Logged

Ric
Full Member
ImageImageImage


member is offline

Avatar




PM

Gender: Male
Posts: 136
xx Re: SYS"CreateThread"
« Reply #6 on: May 2nd, 2017, 2:14pm »

Cheers D

Not sure yet, but is slightly quicker than mine.

Ric
User IP Logged

It's always possible, but not necessarily how you first thought. Chin up and try again.
Pages: 1  Notify Send Topic Print
« Previous Topic | Next Topic »

| |

This forum powered for FREE by Conforums ©
Terms of Service | Privacy Policy | Conforums Support | Parental Controls