Hello,
I have a problem with multiplayer being slow on some computers. I
was debugging and discovered there is nothing wrong with the network
part, but with multithreading. 4-core and more processors are
running this good, and 2-core and less have only 2fps net game. So
far I have main program thread, server thread and client handle
thread, when I am considering 2-player game and I am SERVER and main
program, server, and client thread when I am CLIENT (server is there
just because I want him to be prepared to load quickly). Thats 3
threads on 2-core processor, which means that one core will be
running 2 threads, so it would have to switch between them. Printfs
of elapsed miliseonds show me that the time is currently like 500ms.
And I want to change it to 1ms.
Clients have busy-waiting for update packet and servers have busy-
waiting for impulse packet, and I know that solution would be just
to copy the recv part here, but this is not a complete solution
since as the program will expand, there will be a lot more threads -
so far I do not separate Tic and Display threads - this is all
running on main program, but I want. Also, for every next connected
client there is a next handle (so server would have (3+number of
connected players threads). And I just want this to be slick even on
1-core. I tried to change thread priorities, but it does nothing. If
the switching time is unchangeable, then the perfectly OK solution
would be also to say program, that it should jump on other thread
prematurely - is there something like this?
(I use windows.h HANDLE threads)