thread static (Christopher Helck)
Tue, 8 Aug 1995 14:14:19 GMT

          From comp.compilers

Related articles
thread static (1995-08-08)
Re: thread static (1995-08-15)
Re: thread static (1995-08-18)
Re: thread static (Stefan Monnier) (1995-08-21)
Re: thread static (1995-08-21)
Re: thread static (Roger Barnett) (1995-08-21)
Re: thread static (1995-08-21)
[6 later articles]
| List of all articles for this month |

Newsgroups: comp.compilers
From: (Christopher Helck)
Keywords: parallel, question, comment
Organization: Compilers Central
Date: Tue, 8 Aug 1995 14:14:19 GMT

Is there a technical reason why most languages don't support threads? I would
like to be able to declare in 'C' a variable as "thread static", there would
be a copy of the variable for each thread. A thread can not modify or read
another thread's variable.

This would allow me to write re-entrant routines like this:

typedef struct {...} cache_t;

int foo(....) {
    thread static cache_t cache;

    if (value is in cache)
          return value;
    else {
          value = Do_it_the_hard_way();
          return value;

I'm aware that there are other, more general, ways of writing
reentrant code in a multi-threaded system -- but this way seems kinda
elegant and easy to use. I suppose you could get into serious
trouble if you declare pointers as thread static, but this may have
more to do with 'C' than this concept.

Most multi-threaded extensions to 'C' and languages that directly
support threads (JAVA is the only one I know) concentrate on locking
resources. This is good. But why not go one step further and allow
thread specific variables?

[I'd guess that it's mostly historical -- languages like C weren't designed
with multiprocessors in mind. It'd also take some linker hackery, but that
shouldn't be too hard. -John]

Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.