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 91169
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T22:59:16+00:00 2026-05-10T22:59:16+00:00

I’ve done quite a bit of programming on Windows but now I have to

  • 0

I’ve done quite a bit of programming on Windows but now I have to write my first Linux app.

I need to talk to a hardware device using UDP. I have to send 60 packets a second with a size of 40 bytes. If I send less than 60 packets within 1 second, bad things will happen. The data for the packets may take a while to generate. But if the data isn’t ready to send out on the wire, it’s ok to send the same data that was sent out last time. The computer is a command-line only setup and will only run this program.

I don’t know much about Linux so I was hoping to get a general idea how you might set up an app to meet these requirements. I was hoping for an answer like:

Make 2 threads, one for sending packets and the other for the calculations.

But I’m not sure it’s that simple (maybe it is). Maybe it would be more reliable to make some sort of daemon that just sent out packets from shared memory or something and then have another app do the calculations? If it is some multiple process solution, what communication mechanism would you recommend? Is there some way I can give my app more priority than normal or something similar?

PS: The more bulletproof the better!

  • 1 1 Answer
  • 1 View
  • 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. 2026-05-10T22:59:17+00:00Added an answer on May 10, 2026 at 10:59 pm

    I posted this answer to illustrate a quite different approach to the ‘obvious’ one, in the hope that someone discovers it to be exactly what they need. I didn’t expect it to be selected as the best answer! Treat this solution with caution, because there are potential dangers and concurrency issues…

    You can use the setitimer() system call to have a SIGALRM (alarm signal) sent to your program after a specified number of milliseconds. Signals are asynchronous events (a bit like messages) that interrupt the executing program to let a signal handler run.

    A set of default signal handlers are installed by the OS when your program begins, but you can install a custom signal handler using sigaction().

    So all you need is a single thread; use global variables so that the signal handler can access the necessary information and send off a new packet or repeat the last packet as appropriate.

    Here’s an example for your benefit:

    #include <stdio.h> #include <signal.h> #include <sys/time.h> int ticker = 0;  void timerTick(int dummy) {     printf('The value of ticker is: %d\n', ticker); }  int main() {     int i;      struct sigaction action;     struct itimerval time;      //Here is where we specify the SIGALRM handler     action.sa_handler = &timerTick;     sigemptyset(&action.sa_mask);     action.sa_flags = 0;      //Register the handler for SIGALRM     sigaction(SIGALRM, &action, NULL);      time.it_interval.tv_sec = 1;       //Timing interval in seconds     time.it_interval.tv_usec = 000000; //and microseconds     time.it_value.tv_sec = 0;  //Initial timer value in seconds     time.it_value.tv_usec = 1; //and microseconds      //Set off the timer     setitimer(ITIMER_REAL, &time, NULL);      //Be busy     while(1)         for(ticker = 0; ticker < 1000; ticker++)             for(i = 0; i < 60000000; i++)                 ; } 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
this is what i have right now Drawing an RSS feed into the php,
I have a French site that I want to parse, but am running into
We're building an app, our first using Rails 3, and we're having to build
This could be a duplicate question, but I have no idea what search terms
I have thousands of HTML files to process using Groovy/Java and I need to
I need to clean up various Word 'smart' characters in user input, including but
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and

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.