[Freeciv-Dev] Re: (PR#13351) Meta-ticket: AI and threads
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
Subject: |
[Freeciv-Dev] Re: (PR#13351) Meta-ticket: AI and threads |
From: |
"Per I. Mathisen" <per@xxxxxxxxxxx> |
Date: |
Thu, 13 Jul 2006 00:42:57 -0700 |
Reply-to: |
bugs@xxxxxxxxxxx |
<URL: http://bugs.freeciv.org/Ticket/Display.html?id=13351 >
On Wed, 12 Jul 2006, Jason Dorje Short wrote:
> One problem is portability. This is not an insurmountable problem, but
> pthread is not available on all platforms. I believe it is available
> for windows (pthread-win32) now, but I've never actually used it.
Portability is the least of our worries. All relevant unix variants I know
of support pthreads, including MacOSX, and adding Windows threading code
support should be quite simple.
The big problem is that the AI thread and the main thread will create
inconsistent states for each other. Before we can threadify the AI we need
to make it able to execute discrete operations that depend on no state
data that may be invalidated by other game state changes. But if we do
this, we do not need threading - we can just call the AI function to
execute a few of these discrete operations while waiting for network
packets. Or execute a few network packets while running the AI.
For example: The bodyguard code handles one unit at a time. If interrupted
while executing, it can crash because a unit pointer suddenly points to a
dead unit. But the code stands pretty much on its own, so if network
packets are executed in between handling different units for bodyguarding
duty, that should create no problems.
So I think using threads is neither necessary nor a good idea.
- Per
|
|