Click here to Skip to main content
15,910,797 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
Questionadd char array in specific position in another char array Pin
sadas232341s15-Oct-10 5:41
sadas232341s15-Oct-10 5:41 
AnswerRe: add char array in specific position in another char array Pin
Richard MacCutchan15-Oct-10 5:56
mveRichard MacCutchan15-Oct-10 5:56 
GeneralRe: add char array in specific position in another char array Pin
sadas232341s15-Oct-10 6:38
sadas232341s15-Oct-10 6:38 
GeneralRe: add char array in specific position in another char array Pin
Luc Pattyn15-Oct-10 6:57
sitebuilderLuc Pattyn15-Oct-10 6:57 
GeneralRe: add char array in specific position in another char array Pin
Richard MacCutchan15-Oct-10 7:11
mveRichard MacCutchan15-Oct-10 7:11 
QuestionReading strings from ID3 tag Pin
Danzy8315-Oct-10 4:09
Danzy8315-Oct-10 4:09 
AnswerRe: Reading strings from ID3 tag [modified] Pin
Code-o-mat15-Oct-10 5:13
Code-o-mat15-Oct-10 5:13 
GeneralRe: Reading strings from ID3 tag Pin
Danzy8315-Oct-10 7:26
Danzy8315-Oct-10 7:26 
GeneralRe: Reading strings from ID3 tag Pin
Code-o-mat15-Oct-10 9:46
Code-o-mat15-Oct-10 9:46 
GeneralRe: Reading strings from ID3 tag Pin
Danzy8315-Oct-10 11:25
Danzy8315-Oct-10 11:25 
GeneralRe: Reading strings from ID3 tag Pin
Code-o-mat15-Oct-10 11:39
Code-o-mat15-Oct-10 11:39 
QuestionType Casting Pin
gothic_coder15-Oct-10 1:00
gothic_coder15-Oct-10 1:00 
AnswerRe: Type Casting Pin
Cedric Moonen15-Oct-10 1:02
Cedric Moonen15-Oct-10 1:02 
GeneralRe: Type Casting Pin
gothic_coder15-Oct-10 1:06
gothic_coder15-Oct-10 1:06 
AnswerRe: Type Casting Pin
Sauro Viti15-Oct-10 1:15
professionalSauro Viti15-Oct-10 1:15 
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 

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.