I was looking at the code to get them working and it looks pretty daunting, so i need to make sure they are the right way forward!
Can i specify (and vary, runtime) the amount of processor time (in %, since it will run on different machines, absolute numbers wont work)?
Does it slow the program down compared to a single thread doing the same thing?
What happens when two places in memory are being accessed/changed at the same time or is that not an issue?
Threads
Moderators: hoijui, Moderators
I would not use threads.
there are some ways(mutex,...) but then one thread must wait for the other .
there are many more great "features" of threads which make your life to hell. And finding bugs will be way more fun!
So if you don't need them don't use them.
no, only priority or you are a genius and programme your own :-DCan i specify (and vary, runtime) the amount of processor time (in %, since it will run on different machines, absolute numbers wont work)?
You should do completely different things in your threads or they are slower and more dangerousDoes it slow the program down compared to a single thread doing the same thing?
crash or undefined behaviour :-DWhat happens when two places in memory are being accessed/changed at the same time or is that not an issue?
there are some ways(mutex,...) but then one thread must wait for the other .
there are many more great "features" of threads which make your life to hell. And finding bugs will be way more fun!
So if you don't need them don't use them.
Threads arn't that bad, you just need to be careful.
Threads arn't going to get you any more speed, it just allows you to parallel a lot of tasks. Basically in my AI I'm using them to make sure my Update() calls dont' back up the server.
However, there are a lot of 'gotchas' in threading and such. But if you divide your AI into distict tasks, and are careful about shared objects (or use controls to ensure serial(one at a time) access to them) you should be fine.
Another note is that unless you're using MFC, it's sorta hard to use threads in C++ classes, there's a few gotchas.
Threads arn't going to get you any more speed, it just allows you to parallel a lot of tasks. Basically in my AI I'm using them to make sure my Update() calls dont' back up the server.
However, there are a lot of 'gotchas' in threading and such. But if you divide your AI into distict tasks, and are careful about shared objects (or use controls to ensure serial(one at a time) access to them) you should be fine.
Another note is that unless you're using MFC, it's sorta hard to use threads in C++ classes, there's a few gotchas.
what you really need is a better algorithm, thenkrogothe wrote:Well, i kinda need them :(
either that or a 40Ghz PC (if i get that pc then the AI will be a lot smarter than with threads though)
I just need a way to assign limited processor time to certain functions...
don't expect to achieve that speed.
I've dwelled with some similar issues already, if you tell me what you need that 40Gig for, meby I can help to find a way out.
feel free to send me a private message