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! about 2 threads share one com port

Help! about 2 threads share one com port

Scheduled Pinned Locked Moved C / C++ / MFC
comhelpquestion
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.
  • S Offline
    S Offline
    stans80
    wrote on last edited by
    #1

    Now i have one serial com port, and i want it been shared by 2 threads. Now i am using the binary semaphore to control it. I want to ask is it good? or is it good to use the critical section? Can any body help me compare these method to let me see which one is better? Thanks

    B 1 Reply Last reply
    0
    • S stans80

      Now i have one serial com port, and i want it been shared by 2 threads. Now i am using the binary semaphore to control it. I want to ask is it good? or is it good to use the critical section? Can any body help me compare these method to let me see which one is better? Thanks

      B Offline
      B Offline
      Blake Miller
      wrote on last edited by
      #2

      Microsoft's own documentation makes the claim that the critical section is faster. Critical section can be used for synchronization among many threads within the same process. The critical section can not synchronize separate threads from different processes. It is difficult to make reader/writer type objects with critical sections.

      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