I plan to create multi thread worker model for the network servers using the POSIX pthread library:
Synchronisation:
The Synchronisation is done using MUTEX, EVENT and GATE objects (all based on pthread_mutex and pthread_cond).
A MUTEX grants exclusive access to any resource. An EVENT signals, that something happened. A GATE is a combination of an EVENT with an open counter.
ClientWaitQueue:
This queue contains handles to network clients. For each client, the server must wait for data. Every time a new client is added, an EVENT is signalled.
JobQueue:
This queue contains handles to network clients, where data is available or connection status is changed. Every time a new client is added, the related GATE is opened.
MainThread:
This is the main thread. It creates and manage all other thread and Queues. It waits for EVENT(ClientWaitQueue) to distribute the clients to ReceiveThreads. Therefore it wakes the ReceiveThread with the smallest number of supported clients. Because of a limit of maximal possible elements for wait, additional ReceiveThreads must be created and unneeded terminated.
The main thread also controls the right number of JobThread within a range and also some for standby (fast reaction for jobs).
ListeningThread:
Exact one ListeningThread exists. It listens (POSIX way to wait for a client connection) on several ports for new clients. Depending on it status, a new client is inserted into the ClientWaitQueue or JobQueue.
ReceiveThreads:
ReceiveThreads get clients of the ClientWaitQueue and waits for receiving data or a status change or for a signal send by the MainThread.
If started, it checks the status of its clients and places active clients into the JobWaitQueue. Then ii looks into the ClientWaitQueue and gets as many clients as possible. Then it calls select() to wait for input.
JobThreads:
It waits for the GATE+MUTEX of the JobQueue. If waked, it gets one client from the JobWaitQueue and handles the communication until the client is silent. Then it put the client into the ClientWaitQueue. Then it wait again.
I'll implement this using C++ and POSIX threads on a Linux system.
I have already created similar server models for business. I plan to adapt the C++ classes to create an easy server framework following the above model. The JobThread will only simulate work by sleeping a random time.
Later, if the the framework is ready and tested, only the JobThread class must be modified.
Server Model
Synchronisation:
The Synchronisation is done using MUTEX, EVENT and GATE objects (all based on pthread_mutex and pthread_cond).
A MUTEX grants exclusive access to any resource. An EVENT signals, that something happened. A GATE is a combination of an EVENT with an open counter.
ClientWaitQueue:
This queue contains handles to network clients. For each client, the server must wait for data. Every time a new client is added, an EVENT is signalled.
JobQueue:
This queue contains handles to network clients, where data is available or connection status is changed. Every time a new client is added, the related GATE is opened.
MainThread:
This is the main thread. It creates and manage all other thread and Queues. It waits for EVENT(ClientWaitQueue) to distribute the clients to ReceiveThreads. Therefore it wakes the ReceiveThread with the smallest number of supported clients. Because of a limit of maximal possible elements for wait, additional ReceiveThreads must be created and unneeded terminated.
The main thread also controls the right number of JobThread within a range and also some for standby (fast reaction for jobs).
ListeningThread:
Exact one ListeningThread exists. It listens (POSIX way to wait for a client connection) on several ports for new clients. Depending on it status, a new client is inserted into the ClientWaitQueue or JobQueue.
ReceiveThreads:
ReceiveThreads get clients of the ClientWaitQueue and waits for receiving data or a status change or for a signal send by the MainThread.
If started, it checks the status of its clients and places active clients into the JobWaitQueue. Then ii looks into the ClientWaitQueue and gets as many clients as possible. Then it calls select() to wait for input.
JobThreads:
It waits for the GATE+MUTEX of the JobQueue. If waked, it gets one client from the JobWaitQueue and handles the communication until the client is silent. Then it put the client into the ClientWaitQueue. Then it wait again.
Implementation
I'll implement this using C++ and POSIX threads on a Linux system.
I have already created similar server models for business. I plan to adapt the C++ classes to create an easy server framework following the above model. The JobThread will only simulate work by sleeping a random time.
Later, if the the framework is ready and tested, only the JobThread class must be modified.
Wiimms Mario Kart Fun 2023-09
Mittwochs & Donnerstags
ab 19:30 Uhr CEST (17:30 UTC)
mit Team-Speak (freiwillig)
FC: Wiimm=0432-5226-7951, Leseratte=2880-9868-0945
Mittwochs & Donnerstags
ab 19:30 Uhr CEST (17:30 UTC)
mit Team-Speak (freiwillig)
FC: Wiimm=0432-5226-7951, Leseratte=2880-9868-0945
WIT: Wiimms ISO Tools
Verwaltet Plain ISO, WDF, WIA, CISO, WBFS, FST: kann Extrahieren, Erstellen, Patchen, Mischen und Überprüfen
SZS: Wiimms SZS Tools
Verwaltet SZS-, BRRES-, U8-, BMG-, BREFT-Dateien uvm.
PN ohne persönlichen Charakter werden ignoriert. Support-Anfragen gehören ins Forum.