Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using threads and syncronization with a ring buffer

Status
Not open for further replies.

sph147

Programmer
May 17, 2004
19
US
OK, the basic setup of this project is basically one function that is pulling information from a hardware device when its available in the form of a large character array and then processing that information. The problem is that i can't do too much processing because i don't want to miss any information being sent. My solution, threads and something described to me called a ring buffer.
So now my question is where do I put the functions that do the processing? In the get function that is pulling from the buffer and has the pthread_cond_wait going on, or elsewhere? For that matter where do i put the other function that gets the information? Inside a loop in the put function where the pthread_cond_signal happens, or elsewhere? If anyone has some experience with pthreads or a problem like this, any input would be helpful, thank you.
 
I think you need thw threads

first step
HANDLE hEvent = CreateEvent(.....);
thread 1. read the buffer:
...
....do something....
....
//wait for an event what you will
//create in some other place
WaitForSingleObject(hEvent...);
read the butter there

thread 2. Wake up the event
.....
...if there is some data....
SetEvent(hEvent);
.....

Ion Filipski
1c.bmp
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top