Gamestudio Links
Zorro Links
Newest Posts
Help with plotting multiple ZigZag
by degenerate_762. 04/30/24 23:23
M1 Oversampling
by 11honza11. 04/30/24 08:16
Trading Journey
by howardR. 04/28/24 09:55
Zorro Trader GPT
by TipmyPip. 04/27/24 13:50
Data from CSV not parsed correctly
by jcl. 04/26/24 11:18
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
5 registered members (SBGuy, dr_panther, Ayumi, Quad, AndrewAMD), 920 guests, and 1 spider.
Key: Admin, Global Mod, Mod
Newest Members
firatv, wandaluciaia, Mega_Rod, EternallyCurious, howardR
19050 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 4 1 2 3 4
boost up you game... (use multithreading!) #252827
02/20/09 18:14
02/20/09 18:14

M
mercuryus OP
Unregistered
mercuryus OP
Unregistered
M



Here's a tiny example of implementing threads in you lite-c application.

download example (2.2MB)

But be warned!
Multithreading is not that easy to use and the syncronisation may be a challenge sometimes...

mercuryus

Re: boost up you game... (use multithreading!) [Re: ] #252829
02/20/09 18:20
02/20/09 18:20
Joined: Jan 2003
Posts: 4,615
Cambridge
Joey Offline
Expert
Joey  Offline
Expert

Joined: Jan 2003
Posts: 4,615
Cambridge
so CreateThread just... works? that's interesting, i haven't thought that lite-c was that much compatible to native c code.

Re: boost up you game... (use multithreading!) [Re: Joey] #252830
02/20/09 18:22
02/20/09 18:22

M
mercuryus OP
Unregistered
mercuryus OP
Unregistered
M



The problems may accour in detail.
The cube-demo (multithread_crashes.c) works on my single-core system but crashes at the dualcore system. dunno why?

Re: boost up you game... (use multithreading!) [Re: ] #252833
02/20/09 18:36
02/20/09 18:36
Joined: Oct 2007
Posts: 5,210
İstanbul, Turkey
Quad Online
Senior Expert
Quad  Online
Senior Expert

Joined: Oct 2007
Posts: 5,210
İstanbul, Turkey
add a

while(key_t) wait(1);

after

if(key_t && gv_cubes<MAX_THREADS){

change in speed is magnificant, but idk if it reaaly worths it? (at least from my programmin skill level.)


3333333333
Re: boost up you game... (use multithreading!) [Re: Quad] #252838
02/20/09 19:15
02/20/09 19:15
Joined: Jan 2003
Posts: 4,615
Cambridge
Joey Offline
Expert
Joey  Offline
Expert

Joined: Jan 2003
Posts: 4,615
Cambridge
there are things which should be calculated in their own threads, such as ai or network movement prediction.

Re: boost up you game... (use multithreading!) [Re: Joey] #252845
02/20/09 20:01
02/20/09 20:01

M
mercuryus OP
Unregistered
mercuryus OP
Unregistered
M



Maybe it's possible to handle all particle effects in an separate thread or animations not need to be synchronised with gameplay (maschines/clocks/cloudes/fog/light/create dynamic content...).

But an extra thread is not "extra (so far unused) power" - a busy/overloaded thread can effect the main programm!

Re: boost up you game... (use multithreading!) [Re: ] #252905
02/21/09 10:17
02/21/09 10:17
Joined: Jul 2008
Posts: 894
T
TechMuc Offline
User
TechMuc  Offline
User
T

Joined: Jul 2008
Posts: 894
you can NOT use engine functions in other threads (especially every ent_, effect and _create function will probably lead to an crash). They'll crash randomly, probably because of sync issues

So I would restrict the use of a second or third thread on complex caculations like AI-Pathfinding.

Re: boost up you game... (use multithreading!) [Re: TechMuc] #252923
02/21/09 13:24
02/21/09 13:24
Joined: Sep 2003
Posts: 9,859
F
FBL Offline
Senior Expert
FBL  Offline
Senior Expert
F

Joined: Sep 2003
Posts: 9,859
Yes, things like pathfinding are a good thing to do threaded.

Re: boost up you game... (use multithreading!) [Re: FBL] #252960
02/21/09 20:21
02/21/09 20:21
Joined: Feb 2008
Posts: 3,232
Australia
EvilSOB Offline
Expert
EvilSOB  Offline
Expert

Joined: Feb 2008
Posts: 3,232
Australia
Hey TechMuc, what do you think about the safety of using the threads for
directx vertex manipulations and entity texture changes(ent_setskin)?


"There is no fate but what WE make." - CEO Cyberdyne Systems Corp.
A8.30.5 Commercial
Re: boost up you game... (use multithreading!) [Re: TechMuc] #258233
03/28/09 19:19
03/28/09 19:19
Joined: Jun 2008
Posts: 151
Ukraine
XD1v0 Offline
Member
XD1v0  Offline
Member

Joined: Jun 2008
Posts: 151
Ukraine
mercuryus thank you for this contribution.
Is multithreading integrated in Lite-c,I do not understand can I use multithreading in every system and any processor? Or multithreading may crash in some systems.


A7 Commercial cool
Celeron 1700, GeForce 5500 FX 256mb, 1 Gb Ram
Page 1 of 4 1 2 3 4

Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1