Originally Posted by kami1219 View Post
Well this program works between two network interfaces. It contains two threads, capture and sender. Capture thread captures packets at first interface and stores in a linked list and the other thread retrieves the packets from the list and sends through the other interface and the linked list node is removed. The thing that i have to do is to apply delay on the captured packet before they are stored using linked list. These packets are sent by reading their play out time that is the time stamp of the packet when it is captured plus the amount of delay time added into the time stamp. Such that a kind of delay is added to the packets.

I guess i had mutex on thread one as well. Here one thing, I am using two different mutex variable. I mean, one for each thread. Where it should be implemented and will it be useful in this application where continuously packet are captured and sent. I have to do it urngently so I can't think of any other solution at this point of time and I am new to C and for the first time I implemented pthreads and linked list stuff.

4136 is size of the CaptureBuffer and sizeof(CaptureBuffer) can be used instead. You are right.

I can't understand the remaining contents of your post. What is the shortfall if 4136 is used. I did not get it. I'll change it with sizeof(CaptureBuffer). This is not the problem. How the two process can be synchronized is the main issue here regardless of the number of packets coming to the interface.

Thanks for the post and appreciate your further replies.

Sorry i had another post on the same forum and I have written the synchronization issues in your reply. Other than synchronization issues you can answer the things. This program is not doing anything wrong. I just need you to see the flow of the link list in these two threads and the creation of the list in the main thread. The following can be checked.

1. In main thread: Is the circular list is created correctly.
2. In capture: Is the flow correct in term of extending the list on each new packet. (mutex locks are used. I have omitted some code because I have to see the flow of the list only here)
3. In sender thread: Is smallest packet taken out from the list and sent. Where should I free the node and if I free the node then how can i create new nodes because on each demalloc or each packet sent, one node will be removed and after sometime all the nodes of the list will be removed.

Thanks and regards