Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8939167
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T10:46:14+00:00 2026-06-15T10:46:14+00:00

I have two (or more threads) working parallel. Their purpose is to measure hardware

  • 0

I have two (or more threads) working parallel. Their purpose is to measure hardware devices and they rely on a external hardware stimulus. At a certain point during execution, they trigger an hardware device and wait for the stimulus. But I have only one stimulus device.

Therefore the threads have to wait, till every thread is ready to receive the stimulus. Now another thread (maybe the dispatching main-thread) has to trigger the device and the threads can go on.

What is best practice to synchronise this? Preferable with a dynamic number threads?

EDIT:
We use CVI/Labwindows. That offers some threading but mostly through bad documented macros. I have figured out, how to register threads, start them and wait for them to finish.

There also seems to be tools to create threadsafe variables and locks. But their syntax eludes me, therefore I want/need to build some kind of mutex/semaphore myself.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T10:46:15+00:00Added an answer on June 15, 2026 at 10:46 am
    1. So first all your N worker-threads have to go into “ready mode”
    2. Your stimulus thread sends the stimulus. (It has to wait until all the others are ready)
    3. Then all the threads should start working.

    So between 1. and 2. you need a semaphore (initial count 0, max count nThreads), which is signalled by each worker thread once, and waited for by the stimulus-thread N times.
    Between 2. and 3. you also need a synchronisation, because the worker-threads should wait until the stimulus thread has sent his stimulus. This can also be achieved by a semaphore(initial count 0 max count 1) for each worker-thread.

    pseudo-code for stimulus-thread:

    init stimulus-semaphore and one semaphore for each worker-thread
    start threads
    while (1) {
      for (int i=0;i<nThreads;i++)
        wait for stimulus-semaphore
      do the stimulus-thing
      for (int i=0;i<nThreads;i++)
        signal threads[i] semaphore
    }
    

    pseudo code for worker-thread:

    while (1) {
      signal stimulus-semaphore
      wait for this threads semaphore
      do the work to be done after stimulus was sent
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Sometimes we encounter some devices which have two or more SIM cards. So my
I have two (or more) Java Threads creating, updating and deleting entities from a
OS is Linux, working with pthreads I have two worker threads that run forever,
I have two or more tables which hold values under the same column name.
suppose you have two (or more) classes with private member vectors: class A {
Is this possible to have two (or more) different kinds of cells to be
My issue is that I have two (or more) divs of the same class,
For technical reasons on a site we may have two or more links that
I have a two or more forms on my page in a row. I'm
I'd like to have two main classes (or more) with leiningen, and then be

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.