[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]
<URL: http://bugs.freeciv.org/Ticket/Display.html?id=13351 >
Marko Lindqvist wrote:
>> 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.
>
> Problem with this is that if executing AI function ever takes longer
> than expected, there will be latency in network code. Even if overall
> execution time of AI remains same, changing where certain function
> gets called can cause unacceptable delays. I think this makes writing
> new AI code even harder than threading would.
> Modifying existing code for either this model or threading model
> would be equally hard.
However, threading has that same problem. You have to lock your global
mutexes to protect the shared data before the AI can go to work, but
many (not all) network operations will depend on these same mutexes.
You have the exact same tradeoff: if the AI locks mutexes for a long
time the network code has to block waiting for them, while reducing the
lock length to get more fine-grained locking leads to a higher chance of
bugs.
-jason
|
|