Server Model

      Server Model

      I plan to create multi thread worker model for the network servers using the POSIX pthread library:

      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.

      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.

      Wii Freund schrieb:

      Have you ever analysed, in which stages (wfc, room, racing, .. ) a client is connected to the different servers?
      Exact yesterday, when I talked to Leseratte, I planned an investigation of it.

      Chadderz schrieb:

      Have you thought about using the boost libraries instead of pthreads? This will help to increase portability and gives nicer primitives anyway.
      No, because I know pthreads very well since years, but not boost. I have already implemented sync classes (mutex, event, gate, semaphore) and also thread save circularly queues. I think, I need only hours to adapt these classes into a free source library.

      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.