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

  • Home
  • SEARCH
  • 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 6685959
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T05:07:02+00:00 2026-05-26T05:07:02+00:00

I have a program written in C and running on Linux which acquires streaming

  • 0

I have a program written in C and running on Linux which acquires streaming data from a serial port device every 16 or so ms. This is a time critical piece of code that works fine. Another piece of code plots this data, also in real time, but its timely execution is less important to me than the data acquisition part. That is, I don’t want to wait until all the plotting and drawing functions have finished before polling the serial port again. So I was thinking of having a separate thread do the plotting part of the application, or perhaps have the data acquisition part be the separate thread. I really have next to no experience when it comes to low-level programming, so could someone point me in the right direction? The pseudo-code with which I am working looks something like this:

int xyz; // global variable

int main() {

do_some_preliminary_stuff();

while 1 {
   poll_serial_port_and_fill_xyz_with_new_position_and_repeat();
}

while 1 {
   plot_xyz();
}

return 0;
}

Obviously as written, the code will be stuck in the first while loop, so yeah, threads?

Thanks.

  • 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-05-26T05:07:03+00:00Added an answer on May 26, 2026 at 5:07 am

    Yup, that is the way to go. Have non-main thread be the data acquisition thread, which posts the buffered response to the main/UI thread which does the plotting. Main thread should consume this data for plotting.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a program written in C#, running on a Windows CE device (on
I have a program written in C#, running on Linux using Mono. The program
I have a .NET CF program (running on a Smartphone) and I have written
I have a program written in C++, on Linux, compiled with -g. When I
I have a data acquisition program written in C++ (Visual Studio 6.0). Some clients
I have written a program that invokes a system command from inside: #include <stdlib.h>
I have written a program a.exe which launches another program I wrote, b.exe ,
I have written a program with C#, that creates a logfile and fills this
I have an old program written in Dataflex/PowerFlex from back in the mid 90's
I have an app written in ruby on rails which is running fine on

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.