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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T08:00:14+00:00 2026-06-09T08:00:14+00:00

In my textbook it says: All threads within a process have access to the

  • 0

In my textbook it says:

All threads within a process have access to the same data (share)

But each thread has its own stack, it means local variable is not shared. So what kind of data threads can share.

update:

I found each thread can share global variable, it made me confused, what I learn global global variable is static stack, it shouldn’t be shared by that each thread has its own stack.

  • 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-09T08:00:15+00:00Added an answer on June 9, 2026 at 8:00 am

    Firstly, global and static variables are shared.

    Secondly, memory from malloc that you can reach via a pointer in a global variable, (or via a pointer that…) is shared.

    Thirdly, memory in one thread’s stack that you can reach via a pointer in a global variable, (or via a pointer that…) is shared.

    Really, all of it is shared, all the time, but not all of it is reachable. Thread A can access thread B’s stack, but it won’t have a pointer to do so through unless thread B does something like assign the address of something in its stack to a global (don’t do that) or you’re doing something where you examine the details of the threads and work your way into their stacks (if you’re doing that you’re way more knowledgeable enough about the mechanisms of the pthreads implementation than I am*, so I won’t tell you not to do that, but as a rule it wouldn’t be something to do lightly).

    Mostly you only have to worry about global and static, and can consider anything dealing only in locals to be thread-safe, but that gets blown away once you can reach the latter from the former.

    *Actually, I know little on that, and am mostly basing this on knowledge of threading in other languages. Really, it’s a general threading thing rather than a pthreads specific one, with the exception that some other languages won’t even let you fall into the trap of referencing stack memory from global.

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

Sidebar

Related Questions

I have this problem in my textbook: Given a group of n items, each
These terms were used in my data structures textbook, but the explanation was very
I'm following along in my C# textbook and it says that C# assumes that
I have a modified textbook example as follows (the book is Understanding Ada---a software
I'm looking at code in the textbook: Programming With POSIX Threads by David R.
I've come across these in a textbook I am reading on C#, but I
I am still going through a beginners textbook but nowhere does it explain how
When mapping an ER diagram to a relational schema, my textbook says that in
I have just started reading a C++ textbook and I am having trouble solving
I am currently reading an Algorithm Textbook which is in Java. I have managed

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.