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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T03:40:36+00:00 2026-06-18T03:40:36+00:00

In my Linux app, I have two threads that both try to send a

  • 0

In my Linux app, I have two threads that both try to send a UDP broadcast packet (around 50-500 bytes) using the same UDP client socket. They do this about once every 2-3 seconds. In this case, around the “send(…)” clause, I could put pthread_mutex_lock or pthread_spin_lock. Theory says that if it’s a very small operation, a pthread_spin_lock is more efficient (despite high CPU consumption for that small amount of time). But if its a larger operation, then pthread_mutex_lock is better.

Is sending a UDP packet considered “small enough” to warrant using a pthread_spin_lock, or should I still stick with pthread_mutex_lock?

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-06-18T03:40:37+00:00Added an answer on June 18, 2026 at 3:40 am

    If the only need for locking is because they’re both sending on the same socket, then there’s no need for locking at all – it’s acceptable for two threads to call send() on the same UDP socket at the same time. The data sent won’t be interleaved.

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

Sidebar

Related Questions

We have a linux app that depends on the speed with which the user
I have a Linux app (written in C) that allocates large amount of memory
I have a Linux/c client app that connects to a WCF web service over
I have an embedded Linux app that writes to a file at a fairly
I have two linux apps. One app writes data to an sqlite3 database at
I have one web app works perfectly under linux with jetty-6.1.22. However, when I
I have a cross platform app, I want to compile on Linux. The problem
INFORMIX-SQL 7.32 (SE) Linux Pawnshop App. I have some users who own several pawnshops
I have a developed two small Java applications - a vanilla Java app and
On an Amazon S3 Linux instance, I have two scripts called start_my_app and stop_my_app

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.