473,406 Members | 2,273 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Should threading be in the Standard?

I pinned this to my desktop a while back so I'd remember to look at it:

http://people.redhat.com/drepper/tls.pdf

I just started reading it and realized that there may be a reason to extend the
language to support threading:

Increasing use of threads lead developers to wish for a better way of dealing with
thread-local data. The POSIX thread interface defines interfaces which allow storing
void * objects separate for each thread. But the interface is cumbersome to use. A key
for the object has to be allocated dynamically at run-time. If the key isn't used anymore
it must be freed. While this is already a lot of work and error prone it becomes a real
problem when combined with dynamically loaded code.
To counter these problems it was decided to extend the programming languages to
let the compiler take over the job. For C and C++ the new keyword thread can be
used in variable definitions and declarations. This is not an official extension of the
language but compiler writers are encouraged to implement them to support the new
ABI. Variables defined and declared this way would automatically be allocated local to
each thread:
__thread int i;
__thread struct state s;
extern __thread char *p;
The usefulness of this is not limited to user-programs. The run-time environment
can also take advantage of it (e.g., the global variable errno must be thread-local)
and compilers can perform optimizations which create non-automatic variables. Note
that adding thread to the definition of an automatic variable makes no sense and is
not allowed since automatic variables are always thread-local. Static function-scope
variables on the other hands are candidates, though.

Opinions?
--
"[M]y dislike for the preprocessor is well known. Cpp is essential in C programming, and still important in conventional C++ implementations, but it is a hack, and so are most of the techniques that rely on it. ...I think the time has come to be serious about macro-free C++ programming." - B. S.

Jul 22 '05 #1
1 1261
Steven T. Hatton wrote:
I just started reading it and realized that there may be a reason to extend the
language to support threading:

[...]
Opinions?


There is a thread currently active in comp.lang.c++.moderated and
in comp.std.c++ related to specifically threads and C++ Standard,
perhaps you could read the opinions there.
Jul 22 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

17
by: Andrae Muys | last post by:
Found myself needing serialised access to a shared generator from multiple threads. Came up with the following def serialise(gen): lock = threading.Lock() while 1: lock.acquire() try: next...
12
by: Jerry Sievers | last post by:
Greetings Pythonists; I have limited experience with threaded apps and plenty with old style forked heavyweight multi-processing apps. Using Python 2.3.3 on a Redhat 7.x machine. Wondering...
7
by: Bastian Hammer | last post by:
Hi I´m wondering why there are so few examples with Semaphore. Is it obsolete? I´ve got a Class Data. It offers 2 Threads methods for updating, editing, .. a private dictionary. Now I...
5
by: Roshan | last post by:
This is regarding the article titled "C++ & Double-Checked Locking" by Scott Meyers and Andrei in DDJ July 2004 issue. I think the reasoning in this article is fundamentally flawed due the...
5
by: OpticTygre | last post by:
Heheh...I've got lots of questions today. If I have a loop that calls the same subroutine several times (that subroutine may be processor and network intensive): For i = 1 to 100 Call...
2
by: Juuso Hukkanen | last post by:
I need a list of multithreading unsafe C (C99) functions/features. comp.programming.threads provided an initial list of C:ish functions, with following ANSI C functions: asctime, gmtime,...
4
by: Bryan | last post by:
Im new to threading and am experiencing some confusion as to how to correctly use AfxBeginThread in my singleton class. The code that I want to thread out is in a single function, Init(). Is...
1
by: Seun Osewa | last post by:
Hello, I've tried to run several threading examples in Python 2.5.1 (with Stackless) For example: import threading theVar = 1 class MyThread ( threading.Thread ):
126
by: Dann Corbit | last post by:
Rather than create a new way of doing things: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2497.html why not just pick up ACE into the existing standard:...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.