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. Using CriticalSections and Components

Using CriticalSections and Components

Scheduled Pinned Locked Moved C / C++ / MFC
c++dockerquestion
2 Posts 2 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.
  • P Offline
    P Offline
    Paul Farry
    wrote on last edited by
    #1

    Hi have a quick question(hopefully). I've got a multithreaded ATL component for dealing with RAS. I've been told I should put CriticalSections around certain areas of the system. My container application creates 8 instances of the Component and each instance creates 2 child threads. Do I need some form of parent Container to put in a CriticalSection, or do I put the criticalsection in each instances constructor/destructor.

    I 1 Reply Last reply
    0
    • P Paul Farry

      Hi have a quick question(hopefully). I've got a multithreaded ATL component for dealing with RAS. I've been told I should put CriticalSections around certain areas of the system. My container application creates 8 instances of the Component and each instance creates 2 child threads. Do I need some form of parent Container to put in a CriticalSection, or do I put the criticalsection in each instances constructor/destructor.

      I Offline
      I Offline
      Iain Clarke Warrior Programmer
      wrote on last edited by
      #2

      It is less simple than that. You need to put Enter/LeaveCritSect's around access to shared resources. If each of your instances are independent, then you don't need any critical sections. You may need CritSects in the sub-threads if they can collide when accesses common resources. So the general answer is "it depends". The fewer CriticalSections you have the better as it means your components will run that little bit more smoothly, especially on multi-threaded systems. But it is more important to be safe. I hope this sort-of-helps. Iain.

      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