1

I have a question regarding on how to design the following system:

My system is built of several clients listening to an environment. When a audio threshold is breached they send their information to a server, that has children listening on each connection. The server needs information from all the clients to make the necessary calculations.

Currently the server is working in UNIX and has forked out connections. They are working independently.

What I want to do is to tell the parent (in the server) that information has been sent and it's now time to process it. How should I do it?

I'm thinking of possible different ways to do it:

  1. Using signal()in Unix to somehow tell the parent that something has happened
  2. Convert to Threads and use some wait and notify functions

The signaling is preferable but I cannot figure out how to do it efficiently. Because the following can happen in my system:

  • If all the clients successfully sent information to their children of the server, how can I tell the parent that I'm ready in a efficient way? Don't know/I'm uncertain of how it will process them.
  • The server may not receive information from all clients. So the parent must wait for awhile for all the children but not too long. So I'm guessing some sort of timer?
Mazze
  • 1,354
  • 4
  • 17
  • 35
  • 3
    Are you sure you want to do this with tasks? It seems more like you want to use threads instead. Unfortunately your question is not that clear. – Dacav Jan 14 '13 at 09:28
  • I'll add more information but the question is clearly stated – Mazze Jan 14 '13 at 09:33
  • Please specify the operating system, solutions might differ depending on that. – vladmihaisima Jan 14 '13 at 09:47
  • @KillianDS I can see why this is a bit vague and I really hesitated to post this here cause I knew that some people would find it unrelated cause there is no direct problem. That's why I named it a design question. But read the whole question. The protocol is stated in the title. The communication is also stated in the question. One server, many clients. Server has children that handles each connection seperatly. The clients send information to the server. It's as simple as that. I'll add more text to explain some more of the system. – Mazze Jan 14 '13 at 09:49
  • @vladmihaisima The operating system is described in the question already – Mazze Jan 14 '13 at 09:51
  • @Mazze there are multiple versions of Unix around (eg: Solaris, AIX). If you need it to run on any Unix variant you can specify this as well. – vladmihaisima Jan 14 '13 at 15:37
  • @vladmihaisima I'm running on Debian :) – Mazze Jan 15 '13 at 09:13

2 Answers2

3

Doen't use fork, and don't use signals. Use a thread pool.

Martijn Pieters
  • 1,048,767
  • 296
  • 4,058
  • 3,343
Robert S. Barnes
  • 39,711
  • 30
  • 131
  • 179
2

What about a Unix Domain Socket for an inter-processes communication between children and father?

http://en.wikipedia.org/wiki/Unix_domain_socket

As soon as a child receives data through the TCP connection, the same data will be forwarded to the father process through the Unix Domain Socket and the latter process will be instantly notified

Davide Berra
  • 6,387
  • 2
  • 29
  • 50