Click here to Skip to main content
16,010,488 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Help on Multi-Threaded applicaiton Pin
Mark Salsbery28-Jun-08 12:59
Mark Salsbery28-Jun-08 12:59 
GeneralRe: Help on Multi-Threaded applicaiton Pin
Kiran Satish28-Jun-08 13:24
Kiran Satish28-Jun-08 13:24 
GeneralRe: Help on Multi-Threaded applicaiton Pin
Mark Salsbery28-Jun-08 15:31
Mark Salsbery28-Jun-08 15:31 
GeneralRe: Help on Multi-Threaded applicaiton Pin
Kiran Satish28-Jun-08 15:37
Kiran Satish28-Jun-08 15:37 
GeneralRe: Help on Multi-Threaded applicaiton Pin
Mark Salsbery28-Jun-08 16:16
Mark Salsbery28-Jun-08 16:16 
GeneralRe: Help on Multi-Threaded applicaiton Pin
Kiran Satish28-Jun-08 16:21
Kiran Satish28-Jun-08 16:21 
GeneralRe: Help on Multi-Threaded applicaiton Pin
Mark Salsbery29-Jun-08 7:03
Mark Salsbery29-Jun-08 7:03 
GeneralRe: Help on Multi-Threaded applicaiton Pin
Mark Salsbery29-Jun-08 7:26
Mark Salsbery29-Jun-08 7:26 
Here's what I meant in the last post:
// Camera Thread
While capturing
{
   Capture frame (20ms exposure)
   Add frame data to shared buffer
   Set frame-grabbed event
}

// Processing Thread
While processing
{
   Wait on frame-grabbed event
   Copy data from shared buffer
   Process the data
}

You still need to synchronize access to the shared buffer. Only lock
long enough to copy data to and from the buffer, then release the lock
immediately.

That's all based on ideal situation where processing time is always
~10ms.

In reality, your threads can (and will be) interrupted by other threads
in the system. If it's critical to process every frame, then change the shared
buffer to a FIFO queue of some kind. The grabber thread can queue each frame
and the processing thread can dequeue frames. If the queue holds pointers to
frame buffers, then accessing the queue is fast, which makes lock time shorter.
That's pretty much how I handle audio capture, where I want every sample regardless
of thread timing fluctuations.

Does that make sense? Smile | :)

Mark

Mark Salsbery
Microsoft MVP - Visual C++

Java | [Coffee]

GeneralRe: Help on Multi-Threaded applicaiton Pin
Kiran Satish29-Jun-08 8:33
Kiran Satish29-Jun-08 8:33 
GeneralRe: Help on Multi-Threaded applicaiton Pin
Mark Salsbery29-Jun-08 8:48
Mark Salsbery29-Jun-08 8:48 
GeneralRe: Help on Multi-Threaded applicaiton Pin
Kiran Satish30-Jun-08 10:36
Kiran Satish30-Jun-08 10:36 
GeneralRe: Help on Multi-Threaded applicaiton Pin
Mark Salsbery30-Jun-08 10:53
Mark Salsbery30-Jun-08 10:53 
GeneralRe: Help on Multi-Threaded applicaiton Pin
Kiran Satish30-Jun-08 11:00
Kiran Satish30-Jun-08 11:00 
GeneralRe: Help on Multi-Threaded applicaiton Pin
Mark Salsbery30-Jun-08 11:03
Mark Salsbery30-Jun-08 11:03 
GeneralRe: Help on Multi-Threaded applicaiton Pin
Mark Salsbery30-Jun-08 11:05
Mark Salsbery30-Jun-08 11:05 
GeneralRe: Help on Multi-Threaded applicaiton Pin
Kiran Satish30-Jun-08 13:12
Kiran Satish30-Jun-08 13:12 
GeneralRe: Help on Multi-Threaded applicaiton Pin
Mark Salsbery30-Jun-08 19:08
Mark Salsbery30-Jun-08 19:08 
GeneralRe: Help on Multi-Threaded applicaiton Pin
Kiran Satish1-Jul-08 6:04
Kiran Satish1-Jul-08 6:04 
GeneralRe: Help on Multi-Threaded applicaiton Pin
Mark Salsbery1-Jul-08 6:39
Mark Salsbery1-Jul-08 6:39 
GeneralRe: Help on Multi-Threaded applicaiton Pin
Kiran Satish1-Jul-08 6:53
Kiran Satish1-Jul-08 6:53 
GeneralRe: Help on Multi-Threaded applicaiton Pin
Mark Salsbery1-Jul-08 6:57
Mark Salsbery1-Jul-08 6:57 
GeneralRe: Help on Multi-Threaded applicaiton Pin
Kiran Satish1-Jul-08 7:01
Kiran Satish1-Jul-08 7:01 
GeneralRe: Help on Multi-Threaded applicaiton Pin
Mark Salsbery1-Jul-08 7:09
Mark Salsbery1-Jul-08 7:09 
GeneralRe: Help on Multi-Threaded applicaiton Pin
Kiran Satish1-Jul-08 7:05
Kiran Satish1-Jul-08 7:05 
GeneralRe: Help on Multi-Threaded applicaiton Pin
Mark Salsbery1-Jul-08 7:18
Mark Salsbery1-Jul-08 7:18 

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.