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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T10:07:11+00:00 2026-05-31T10:07:11+00:00

There is one thread and only one thread which will be writing/modifying a data

  • 0

There is one thread and only one thread which will be writing/modifying a data structure. The data structure has one field which is a socket descriptor opened by the writing thread. Two other threads will be reading the data structure and will have to do something (like polling the socket(s) stored in the structure for input data).

One thread will read one global structure written by the writing thread while the other thread will read a second global structure. In essence, the two reading threads are not accessing the same global structure.

My question is, if the writing thread makes changes to the data structure which maybe adding more records in the data structure or deleting them, will the process crash? Is there any room for any kind of instance where a run-time crash can occur?

P.S. I’m using POSIX Threads working on a Linux environment

  • 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-31T10:07:12+00:00Added an answer on May 31, 2026 at 10:07 am

    Is there any room for any kind of instance where a run-time crash can
    occur

    Short answer: most likely yes. You need to protect the data structure with some kind of locking. Pthread mutexes come to mind.

    Longer answer: Think about a linked list. Think about adding an element or deleting one. Typically you need to modify more than one aspect of that list, for example you need to modify 2 pointers. Now ask yourself: what will happen if:

    • The writer thread starts changing some aspect of the list (like updating the next pointer) but isn’t quite done before it gets interrupted
    • The reader thread tries to read from the list

    EDIT

    As Blagovest Buyukliev mentions in the comments, lock-free data structures usually provide more performance so you could investigate that route.

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

Sidebar

Related Questions

Are there any concurrency problems with one thread reading from one index of an
I'm looking for a standard dual-map structure - is there one implemented in std/boost/another
In my application the main thread creates two joined threads; one which waits for
I am writing an application that will display serial/USB data at a rate of
Background Given: a set of threads each thread has its own data source objects
I'm writing an iOS application that will play audio instructions as one of it's
I need some help dealing with three Threads in Android One thread is the
Is there one method or property in the .NET Framework that tells if an
Network file systems are offered by Windows and (L)Unix. Is there one for IBM
There's one specific feature that I wish was in the .NET framework, but isn't.

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.