Threads and Strings ?

Everything else that doesn't fall into one of the other PB categories.
localmotion34
Enthusiast
Enthusiast
Posts: 665
Joined: Fri Sep 12, 2003 10:40 pm
Location: Tallahassee, Florida

Post by localmotion34 »

ok, having a dual processor machine as my main computer for school and extremely high end imaging, data analysis, and some gaming, the problem i often run into is that an application is NOT optimized for dual processors. while some apps may create somewhat separate threads, the main process often has to "wait" until the separate calculating or manipulating thread finishes before returning the final result.

the best, fastest, most lean and mean code for DNA sequence analysis makes full use of my dual Xeon processors. There are some DNA sequences of about 8000 base pairs in length that i must use regular expressions to search through for enzyme sites (string sequences) anywhere from 4-15 in length that can occur ay any and every place in the string.

so what i do is pass the 8000 character string to a thread procedure, and search for locations each reg exp occurs, store results in it a structured linked list, start a new thread (thread created by a thread) that sorts the result, and re-postmessage_() with the final result. the subclassed listbox i use to display the results processes (peekmessage) the last postmessage_() or sendmessage_() (a message i call #DNA_sequence_done) and adds a listbox entry in real time for each of the linkedlist elements as they are analyzed with the appropriate information stored in the structure of the list.

the key here is the subclassing and getting the heavy working thread working in tandem so that your program execution does not halt or slow.

the commercial program SEQUENCER takes anywhere from 1-2 min to do what my program takes 15-20 sec. ive never tested mine on a single processor machine, so dont think i wrote groundbreaking code. i just know that dual processors (really managed by the OS) can perform this type of task and i wrote my code accordingly.

because i wrote the program in my office at school and made it availabe to my university department, and scientists are using this in competetively government funded research, i need to ask FSU legal if i am allowed to post the source. if i can, ill completely show how to really optimize for dual, hyperthreaded, and dual core, processing.

Code: Select all

!.WHILE status != dwPassedOut
! Invoke AllocateDrink, dwBeerAmount
!MOV Mug, Beer
!Invoke Drink, Mug, dwBeerAmount
!.endw
dell_jockey
Enthusiast
Enthusiast
Posts: 767
Joined: Sat Jan 24, 2004 6:56 pm

Post by dell_jockey »

Localmotion,

now that would be interesting to study! I hope you are allowed to release your sources!
cheers,
dell_jockey
________
http://blog.forex-trading-ideas.com
dell_jockey
Enthusiast
Enthusiast
Posts: 767
Joined: Sat Jan 24, 2004 6:56 pm

Post by dell_jockey »

Localmotion,

would it be legally ok for you to just publish the multi-core/processor threading code, without all the DNA sequencing stuff?
cheers,
dell_jockey
________
http://blog.forex-trading-ideas.com
WilliamL
Addict
Addict
Posts: 1224
Joined: Mon Aug 04, 2008 10:56 pm
Location: Seattle, USA

Re: Threads and Strings ?

Post by WilliamL »

old thread (pun) but I was searching for...
Could one of you thread gurus write a brief "using threads with purebasic (for dummies) tutorial or guide?
and came across

https://ninelizards.com/purebasic/pureb ... #7_threads

this is interesting too:

viewtopic.php?f=13&t=75909
MacBook Pro-M1 (2021), Sonoma 14.4.1, PB 6.10LTS M1
User avatar
blueb
Addict
Addict
Posts: 1044
Joined: Sat Apr 26, 2003 2:15 pm
Location: Cuernavaca, Mexico

Re: Threads and Strings ?

Post by blueb »

Maybe this multi-threaded example will be of use.... :idea:

viewtopic.php?p=424174#p424174
- It was too lonely at the top.

System : PB 6.10 LTS (x64) and Win Pro 11 (x64)
Hardware: AMD Ryzen 9 5900X w/64 gigs Ram, AMD RX 6950 XT Graphics w/16gigs Mem
WilliamL
Addict
Addict
Posts: 1224
Joined: Mon Aug 04, 2008 10:56 pm
Location: Seattle, USA

Re: Threads and Strings ?

Post by WilliamL »

blueb
That some 'heavy duty' info! I think that is why threads are so mysterious.

Little John posted this: viewtopic.php?f=13&t=75909#p559126
The following works fine for me:
The "background job" is done in a thread.
Each time a piece of work is finished, the thread uses PostEvent() to tell the main program code about this.
When the main program code receives such an event, it updates the progressbar accordingly.
I think a simple example of what Little John was referring to above was what captain_skank was looking for. ( viewtopic.php?f=13&t=75909#p559125 )
MacBook Pro-M1 (2021), Sonoma 14.4.1, PB 6.10LTS M1
Post Reply