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.
Threads and Strings ?
-
- Enthusiast
- Posts: 665
- Joined: Fri Sep 12, 2003 10:40 pm
- Location: Tallahassee, Florida
Code: Select all
!.WHILE status != dwPassedOut
! Invoke AllocateDrink, dwBeerAmount
!MOV Mug, Beer
!Invoke Drink, Mug, dwBeerAmount
!.endw
-
- Enthusiast
- Posts: 767
- Joined: Sat Jan 24, 2004 6:56 pm
-
- Enthusiast
- Posts: 767
- Joined: Sat Jan 24, 2004 6:56 pm
Re: Threads and Strings ?
old thread (pun) but I was searching for...
https://ninelizards.com/purebasic/pureb ... #7_threads
this is interesting too:
viewtopic.php?f=13&t=75909
and came acrossCould one of you thread gurus write a brief "using threads with purebasic (for dummies) tutorial or guide?
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
Re: Threads and Strings ?
- 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
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
Re: Threads and Strings ?
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
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
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 )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.
MacBook Pro-M1 (2021), Sonoma 14.4.1, PB 6.10LTS M1