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

  • Home
  • SEARCH
  • 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 848731
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T06:59:24+00:00 2026-05-15T06:59:24+00:00

I am working on a mobile platform over Nucleus RTOS. It uses Nucleus Threading

  • 0

I am working on a mobile platform over Nucleus RTOS. It uses Nucleus Threading system but it doesn’t have support for explicit thread local storage i.e, TlsAlloc, TlsSetValue, TlsGetValue, TlsFree APIs. The platform doesn’t have user space pthreads as well.

I found that __thread storage modifier is present in most of the C++ compilers. But i don’t know how to make it work for my kind of usage. How does __thread keyword can be mapped with explicit thread local storage? I read many articles but nothing is so clear for giving me the following basic information

  1. will __thread variable different for each thread ?
  2. How to write to that and read from it ? does each thread has exactly one copy of the variable ?

following is the pthread based implementation:

pthread_key_t m_key;

struct Data : Noncopyable {
        Data(T* value, void* owner) : value(value), owner(owner) {}


        int* value;

  };


inline ThreadSpecific()
{
    int error = pthread_key_create(&m_key, destroy);
    if (error)
        CRASH();
}

inline ~ThreadSpecific()
{
    pthread_key_delete(m_key); // Does not invoke destructor functions.
}

inline T* get()
{
    Data* data = static_cast<Data*>(pthread_getspecific(m_key));
    return data ? data->value : 0;
}

inline void set(T* ptr)
{
    ASSERT(!get());
    pthread_setspecific(m_key, new Data(ptr, this));
}

How to make the above code use __thread way to set & get specific value ? where/when does the create & delete happen?

If this is not possible, how to write custom pthread_setspecific, pthread_getspecific kind of APIs.

I tried using a C++ global map and index it uniquely for each thread and retrieved data from it. But it didn’t work well.

  • 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-15T06:59:25+00:00Added an answer on May 15, 2026 at 6:59 am

    I alwasy used the ACE library when needing thread local storage. I don’t know if it is available for your system. If so check out class ACE_TSS.

    For the __thread keyword, there is an wikipedia page, where it is described.

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

Sidebar

Related Questions

So I'm working on a mobile platform application that I'd like to have users
I'm currently working on a cross-platform mobile app and have gone through the process
I'm working on a Qt mobile app for the symbian platform. I have a
I am working on a mobile ticket sales app. The system allows users to
I am working on a cross-platform mobile game for Android and iOS devices. I
I am working on a mobile app on the Android platform (and going forward
I am working on a cross platform mobile application using phonegap (html,javascript) problem is
Need to be cross-device -working for every mobile manufacturer that gives support to JavaME
I am developing an application in java for a mobile platform. The program uses
I am working on a mobile library app. I have a 3-4 db files

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.