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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T23:55:35+00:00 2026-05-27T23:55:35+00:00

I am reading from a thread local variable in my code like this, //

  • 0

I am reading from a thread local variable in my code like this,

// tid_local is declared as __thread int tid_local;
long tid = tid_local

Looking around the dissassembled code, I saw something like this, which I suspect is the instruction which assigns tid by reading tid_local.

movslq %fs:0xfffffffffffffffc,%rbx

Now my question is if this can really be the instruction which is doing this, that is, reading from the local thread variable and if gcc always uses the fs segment for storing thread local variables. How is this supposed to work?

  • 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-27T23:55:35+00:00Added an answer on May 27, 2026 at 11:55 pm

    Yes, this could well be the right instruction. From the gcc manual:

    -mtls-direct-seg-refs

    -mno-tls-direct-seg-refs

    Controls whether TLS variables may be accessed with offsets from the TLS segment register (%gs for 32-bit, %fs for 64-bit), or whether the thread base pointer must be added. Whether or not this is legal depends on the operating system, and whether it maps the segment to cover the entire TLS area.

    edit Here is an excellent link suggested by @janneb in the comments: http://www.akkadia.org/drepper/tls.pdf

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

Sidebar

Related Questions

Could I close tcp::socket in different thread from the sync-reading thread? It looks like:
I would like to stop a thread in mid execution. From reading around, I
In the code below I have a StreamReader reading from a network stream. This
Are there any concurrency problems with one thread reading from one index of an
I'm reading from a byte stream that contains a series of variable length descriptors
Basically I have a thread reading from c++ std::istream using istream& getline ( istream&
I am little confused... Is it true that reading\writing from several threads all except
It's my understanding that if two threads are reading from the same piece of
I'm reading from a binary data file which is written by invoking the following
I'm reading from the standard input using the read() system call but there's a

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.