News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests

Main Menu

same thread proc for many threads?

Started by daydreamer, February 21, 2021, 12:47:43 AM

Previous topic - Next topic

daydreamer

first I start 4 threads,1 thread=one animated object moving around
first call to random positions/direction and while loop keeping most things in registers,output to struct of data and input,and sleep some millis,exiting while loop if detect destroyed or moved far away from screen

how do I solve the get right data with lea ebx,struct+esi*size of struct,thread  #0,#1,#2,#3...to point to right struct of positions,directions,Iconhandle ...?

so if I spawn lots of threads,more than cores,I want to code it right so Sleep or other function,makes OS switch to another thread,while the thread sleeps
good idea to equate registers with variable names?

my none asm creations
https://masm32.com/board/index.php?topic=6937.msg74303#msg74303
I am an Invoker
"An Invoker is a mage who specializes in the manipulation of raw and elemental energies."
Like SIMD coding

TouEnMasm

Normal data accessing would work.
Perhaps a little code to explain the problem ?.
The Only one problem is with shared data,you don't seem to have this one ?.
https://docs.microsoft.com/en-us/windows/win32/procthread/thread-local-storage
Fa is a musical note to play with CL

daydreamer

If I use same threadloop for all objects,in array of struct
In global memory
For example
Db "spider",0
Maxhp,currenthp, level
Xpos,ypos,xsize,ysize,xdelta, ydelta,angle
Iconhandle
Status,alive,dead,destroyed
Followed by example mice,cat,dog
1: starting 4 threads,how do I get it right thread output to right struct?thread0 first structure, thread 4, fourth structure?

2: wmpaint drawing objects,mouseclick messages reads data+ one thread reads the others data for test collision detection

Sorry I got stuck on this
my none asm creations
https://masm32.com/board/index.php?topic=6937.msg74303#msg74303
I am an Invoker
"An Invoker is a mage who specializes in the manipulation of raw and elemental energies."
Like SIMD coding

TouEnMasm


The CreateThread  lpParameter allow to pass a parameter to the thread.
The first thhread recieve zero as parameter and the thread 4 recieve 3
.data
MyStruct MACHIN 4 dup(<>) ;MACHIN = a defined structure

Fa is a musical note to play with CL

daydreamer

Quote from: TouEnMasm on February 22, 2021, 05:11:29 AM

The CreateThread  lpParameter allow to pass a parameter to the thread.
The first thhread recieve zero as parameter and the thread 4 recieve 3
.data
MyStruct MACHIN 4 dup(<>) ;MACHIN = a defined structure
thanks
https://docs.microsoft.com/en-us/windows/win32/api/processthreadsapi/nf-processthreadsapi-createthread
so stack space in 64bit,could be how low Hutch,because I can use loads of registers instead to save values, mov to unused register?
SUSPENDED flag,seem I am possible to create many number of threads/objects I gonna use and fill structs with data and activate when needed
was thinking of first understand howto use SIMT
my none asm creations
https://masm32.com/board/index.php?topic=6937.msg74303#msg74303
I am an Invoker
"An Invoker is a mage who specializes in the manipulation of raw and elemental energies."
Like SIMD coding

daydreamer

I am going thru exercises,tutorials,example programs so I solved that,but missing process.h header file,but seem some could be fixed with wrappers,like with createthread -_beginthread

unsynchronized thread exercise:its all random output order,printing out 0-max number of threads,if I have a threadripper or other cpu with many cores,would OS be able to start more threads in order?
my none asm creations
https://masm32.com/board/index.php?topic=6937.msg74303#msg74303
I am an Invoker
"An Invoker is a mage who specializes in the manipulation of raw and elemental energies."
Like SIMD coding

TouEnMasm


process.h is in the windows SDK all versions and translated for masm in the translated sdk http://luce.yves.pagesperso-orange.fr/header.htm
Fa is a musical note to play with CL

daydreamer

my none asm creations
https://masm32.com/board/index.php?topic=6937.msg74303#msg74303
I am an Invoker
"An Invoker is a mage who specializes in the manipulation of raw and elemental energies."
Like SIMD coding

daydreamer

Quote from: TouEnMasm on February 21, 2021, 04:29:25 AM
Normal data accessing would work.
Perhaps a little code to explain the problem ?.
The Only one problem is with shared data,you don't seem to have this one ?.
https://docs.microsoft.com/en-us/windows/win32/procthread/thread-local-storage
seem after having several proc using ,LOCAL variables,LOCAL arrays,so I should measure esp at the start of thread and max esp,so I can use optimal stack size,because max 2048 thread with standard max 1mb stack size can become too big 2048*1mb
my none asm creations
https://masm32.com/board/index.php?topic=6937.msg74303#msg74303
I am an Invoker
"An Invoker is a mage who specializes in the manipulation of raw and elemental energies."
Like SIMD coding

daydreamer

I am testrunning 1 main thread and 4 workerthreads and use print
loc x,y together with print inside threads doesnt work,it text appears similar randomness that output from 4 threads does
,is that whats not threadsafe runtime?
my none asm creations
https://masm32.com/board/index.php?topic=6937.msg74303#msg74303
I am an Invoker
"An Invoker is a mage who specializes in the manipulation of raw and elemental energies."
Like SIMD coding

six_L

#10
No codes, No facts.
are we guessing what's happen?
Say you, Say me, Say the codes together for ever.

hutch--


daydreamer

loc macro doesnt work with print inside threads,only main thread it works
going local variables (c-style) ,so I can take advantage of each thread has separate 1mb stack, LOCAL variable will be threadspecific
my none asm creations
https://masm32.com/board/index.php?topic=6937.msg74303#msg74303
I am an Invoker
"An Invoker is a mage who specializes in the manipulation of raw and elemental energies."
Like SIMD coding

TouEnMasm


First step is to preserve the register esi edi ,startthread proc don't do that.
strange also

Quote
ret 16                            <<<<<<<<<<<<<<<<<<<<<<< ????
spawn endp

Fa is a musical note to play with CL

daydreamer

Quote from: TouEnMasm on March 04, 2021, 08:05:14 PM

First step is to preserve the register esi edi ,startthread proc don't do that.
strange also

Quote
ret 16                            <<<<<<<<<<<<<<<<<<<<<<< ????
spawn endp

thanks,I fix the first
second is plan ahead
spawn proc has 4 arguments,so more control with read from readfile or som data section as alternative to randomized spawn and maybe I want to control spawns,so they trigger spawned directly when player comes close to some place/xyz coordinate
testing purposes random generator is good enough for now
my none asm creations
https://masm32.com/board/index.php?topic=6937.msg74303#msg74303
I am an Invoker
"An Invoker is a mage who specializes in the manipulation of raw and elemental energies."
Like SIMD coding