Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Help on Multi-Threaded applicaiton [modified]

Help on Multi-Threaded applicaiton [modified]

Scheduled Pinned Locked Moved C / C++ / MFC
questionperformancehelpannouncement
41 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Kiran Satish

    My images are only 8bpp(0-255) and I use unsigned char pointer for image data. I am not sure which thread is slowing down and as fas as I know I dont have any critical sections. Here is the order- BipBuffer ImageBuffer; ImageBuffer.AllocateBuffer(128*m_FrameBufferSize) //m_FrameBufferSize = 512x512 -Main Thread (camera thread)- // this controls the processing thread while (camthread) take image (~20.5msec) copy image data into shared buffer set event to processing thread -Processing thread- while (processing thread) wait for event from camera copy image data from shared buffer to processing buffer if(saveimage) copy image data from shared buffer to buffer for saving image Set event to save image thread do the processing on image data in processing buffer Update displays for results -Save Image thread- BYTE* pData wait for save image event pData = ImageBuffer.Reserve(m_FrameBufferSize, iResult) memcpy(pData, m_pImageBuffer, iResult) ImageBuffer.Commit(iResult) //iResult will be equal to m_FrameBufferSize -Store Image thread- //this thread runs continuously until BipBuffer == NULL while ((pData = ImageBuffer.GetContiguousBlock(iResult)) != NULL){ create filename write image data to a file (I tried writing in two ways to see if there will be any difference in speed, one as a tiff format and also as a binary file) ImageBuffer.DecommitBlock(iResult)} I think I might just use a standard circular buffer of my own rather than BipBuffer as I see there is something going on when using it. When I run the program loop for 15sec, the number of images being stored are increasing from one run to another. Hope I am clear :) . If I comment out writing image data to a file in store image thread, everything runs fine at desired speed. -thanks

    PKNT

    S Offline
    S Offline
    Simon Cooke
    wrote on last edited by
    #41

    If I'm reading this correctly, and you've got two threads running, you might need to add some critical sections or events around your use of the BipBuffer; as the code stands it's not threadsafe.

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups