Click here to Skip to main content
15,902,918 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionOne genneral question on dual buffers design with multi-threading Pin
SAMZC14-Oct-10 23:42
SAMZC14-Oct-10 23:42 
AnswerRe: One genneral question on dual buffers design with multi-threading Pin
CPallini14-Oct-10 23:49
mveCPallini14-Oct-10 23:49 
GeneralRe: One genneral question on dual buffers design with multi-threading Pin
Rajesh R Subramanian15-Oct-10 1:01
professionalRajesh R Subramanian15-Oct-10 1:01 
GeneralRe: One genneral question on dual buffers design with multi-threading Pin
CPallini15-Oct-10 2:35
mveCPallini15-Oct-10 2:35 
GeneralRe: One genneral question on dual buffers design with multi-threading Pin
Rajesh R Subramanian15-Oct-10 22:10
professionalRajesh R Subramanian15-Oct-10 22:10 
GeneralRe: One genneral question on dual buffers design with multi-threading Pin
SAMZC15-Oct-10 23:42
SAMZC15-Oct-10 23:42 
AnswerRe: One genneral question on dual buffers design with multi-threading Pin
Cedric Moonen14-Oct-10 23:55
Cedric Moonen14-Oct-10 23:55 
GeneralRe: One genneral question on dual buffers design with multi-threading Pin
SAMZC15-Oct-10 20:37
SAMZC15-Oct-10 20:37 
Thanks. I am using winpcap to capture raw data from network, but not using winsocket to do that.

Usually, I used one buffer to do it whit WinPCAP driver to capture data from ethernet switch. But the perforance is not satisfied.

With one buffer, the capture thread put data into the buffer after data arrived. And signal the consumer to read it from the buffer. Here I suspect the wait consumption will decrease the performance.So I intend to introduce another buffer to increase the performance. The capture thread and the processing thread can work paralelly in some method.

With one buffer ...Capture thread:
enter critical section
put data into buffer[]
signal the event to tell processing thread.
leave critical section

And the processing thread:
wait for single object and get signal...
enter critical section
read data into its buffer to release the shared buffer
leave critical section

I am thinking if I use 2 buffers(bufferA + bufferB). The capture thread and the procesing thread may work parallely. In worst case, one of them must wait one of the buffers release. But in normal busy case, each thread can access one of the buffer simutannously.

Like this...The capture thread want to put data into the buffer. It begins to use the buffer from bufferA. And then use bufferB. So it will use the buffers as a sequence A...B...A...B...A...B...If data incomes, it only need to check the target buffer status.If available, put data into it and signal the processing thread.

From the processing thread aspect, it will use the buffers as a sequence B...A...B....A...B...A...If get signal and it indicates data incoming to process. Then it will access target buffer to read data and release the signal to indicate the buffer is empty now and tell the capture thread its availability.

Ok. It's just my thought on this question. No practice till now. I want to get some expirenced advice and confirm the solution is ok before I start. Sniff | :^)

Anyway, thanks for any of your help here.

Sam/BR
The world is fine.

GeneralRe: One genneral question on dual buffers design with multi-threading Pin
Rick York18-Oct-10 7:11
mveRick York18-Oct-10 7:11 
GeneralRe: One genneral question on dual buffers design with multi-threading Pin
SAMZC18-Oct-10 18:22
SAMZC18-Oct-10 18:22 
AnswerRe: One genneral question on dual buffers design with multi-threading Pin
Rajesh R Subramanian15-Oct-10 1:05
professionalRajesh R Subramanian15-Oct-10 1:05 
GeneralRe: One genneral question on dual buffers design with multi-threading Pin
SAMZC15-Oct-10 20:53
SAMZC15-Oct-10 20:53 
AnswerRe: One genneral question on dual buffers design with multi-threading Pin
federico.strati15-Oct-10 1:40
federico.strati15-Oct-10 1:40 
GeneralRe: One genneral question on dual buffers design with multi-threading Pin
SAMZC15-Oct-10 20:51
SAMZC15-Oct-10 20:51 
GeneralRe: One genneral question on dual buffers design with multi-threading Pin
SAMZCN15-Oct-10 23:31
SAMZCN15-Oct-10 23:31 
GeneralRe: One genneral question on dual buffers design with multi-threading Pin
federico.strati17-Oct-10 20:45
federico.strati17-Oct-10 20:45 
GeneralRe: One genneral question on dual buffers design with multi-threading Pin
SAMZC16-Oct-10 7:57
SAMZC16-Oct-10 7:57 
GeneralRe: One genneral question on dual buffers design with multi-threading Pin
federico.strati17-Oct-10 20:50
federico.strati17-Oct-10 20:50 
GeneralRe: One genneral question on dual buffers design with multi-threading Pin
SAMZCN18-Oct-10 2:16
SAMZCN18-Oct-10 2:16 
GeneralRe: One genneral question: there were errors in my code !!! Pin
federico.strati19-Oct-10 22:25
federico.strati19-Oct-10 22:25 
QuestionHello calling function between two different processes Pin
nah133714-Oct-10 22:42
nah133714-Oct-10 22:42 
AnswerRe: Hello calling function between two different processes Pin
CPallini14-Oct-10 22:47
mveCPallini14-Oct-10 22:47 
AnswerRe: Hello calling function between two different processes Pin
Rajesh R Subramanian15-Oct-10 0:52
professionalRajesh R Subramanian15-Oct-10 0:52 
QuestionEncrypt / Decrypt a file Pin
mesajflaviu14-Oct-10 21:51
mesajflaviu14-Oct-10 21:51 
AnswerRe: Encrypt / Decrypt a file Pin
CPallini14-Oct-10 22:32
mveCPallini14-Oct-10 22:32 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.