caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] Thread Local Storage
@ 2006-02-13  4:29 Jonathan Roewen
  2006-02-13 10:05 ` Vincenzo Ciancia
  0 siblings, 1 reply; 7+ messages in thread
From: Jonathan Roewen @ 2006-02-13  4:29 UTC (permalink / raw)
  To: OCaml

Hi,

I'm wondering if it'd be at all possible to somehow implement
something akin to TLS under the ocaml bytecode vmthreads package.

This is for having software-based processes, and globals whose
instances are unique to a given process.

Jonathan


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Thread Local Storage
  2006-02-13  4:29 [Caml-list] Thread Local Storage Jonathan Roewen
@ 2006-02-13 10:05 ` Vincenzo Ciancia
  2006-02-14  2:40   ` [Caml-list] " Jonathan Roewen
  0 siblings, 1 reply; 7+ messages in thread
From: Vincenzo Ciancia @ 2006-02-13 10:05 UTC (permalink / raw)
  To: caml-list

Jonathan Roewen wrote:

> I'm wondering if it'd be at all possible to somehow implement
> something akin to TLS under the ocaml bytecode vmthreads package.
> 
> This is for having software-based processes, and globals whose
> instances are unique to a given process.

I don't know if there are better solutions but at least you can use an
hashtable or a balanced tree or whatever (protected by a mutex) indexed on
thread identifiers as reported by  "Thread.id (Thread.self ())" or
something similar.

Bye

Vincenzo

-- 
Please note that I do not read the e-mail address used in the from field but
I read vincenzo_ml at yahoo dot it
Attenzione: non leggo l'indirizzo di posta usato nel campo from, ma leggo
vincenzo_ml at yahoo dot it


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [Caml-list] Re: Thread Local Storage
  2006-02-13 10:05 ` Vincenzo Ciancia
@ 2006-02-14  2:40   ` Jonathan Roewen
  2006-02-14  4:06     ` skaller
  0 siblings, 1 reply; 7+ messages in thread
From: Jonathan Roewen @ 2006-02-14  2:40 UTC (permalink / raw)
  Cc: caml-list

> I don't know if there are better solutions but at least you can use an
> hashtable or a balanced tree or whatever (protected by a mutex) indexed on
> thread identifiers as reported by  "Thread.id (Thread.self ())" or
> something similar.

Yes, but that means that you need functions to lookup the values,
rather than having the value have process-dependent values globally.
Think like Sys.argv (etc) -- this'd require changes to the interfaces
(not such a big deal, since I have control over all interfaces).

But to go even further, having distinct descriptors for
stdin/stdout/stderr, then you could see where this would become
unstuck. Whilst I have code that can change the value transparently
for stdin/stdout/stderr, this'd make for a bigger process switch if I
had to do for all TLS values.

Perhaps what I need would require a change to the compiler and runtime
=/ What I'd also want to avoid, but I guess I'll have to face the
music....

Jonathan


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [Caml-list] Re: Thread Local Storage
  2006-02-14  2:40   ` [Caml-list] " Jonathan Roewen
@ 2006-02-14  4:06     ` skaller
  2006-02-14 21:40       ` Florian Weimer
  0 siblings, 1 reply; 7+ messages in thread
From: skaller @ 2006-02-14  4:06 UTC (permalink / raw)
  To: Jonathan Roewen; +Cc: caml-list

On Tue, 2006-02-14 at 15:40 +1300, Jonathan Roewen wrote:
[on TLS]

I wonder why you need this? You're providing a new OS with new
build system, tools, etc.

TLS is entirely a legacy application backwards compatibility hack
designed to support badly designed C applications. It has no
function in new code and should NOT be supported in an OS layer
that doesn't need to support broken legacy apps.

Threads already have local storage -- their stacks. That's
all you need.

-- 
John Skaller <skaller at users dot sf dot net>
Felix, successor to C++: http://felix.sf.net


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [Caml-list] Re: Thread Local Storage
  2006-02-14  4:06     ` skaller
@ 2006-02-14 21:40       ` Florian Weimer
  2006-02-14 22:21         ` skaller
  0 siblings, 1 reply; 7+ messages in thread
From: Florian Weimer @ 2006-02-14 21:40 UTC (permalink / raw)
  To: skaller; +Cc: Jonathan Roewen, caml-list

> TLS is entirely a legacy application backwards compatibility hack
> designed to support badly designed C applications.

TLS helps a lot on a certain register-starved architecture because you
don't need to keep a pointer to the thread data structure around in
case you don't need it (but called functions might).  And you still
need some thread-local variables for various management purposes.


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [Caml-list] Re: Thread Local Storage
  2006-02-14 21:40       ` Florian Weimer
@ 2006-02-14 22:21         ` skaller
  2006-03-01  7:37           ` Florian Weimer
  0 siblings, 1 reply; 7+ messages in thread
From: skaller @ 2006-02-14 22:21 UTC (permalink / raw)
  To: Florian Weimer; +Cc: caml-list

On Tue, 2006-02-14 at 22:40 +0100, Florian Weimer wrote:
> > TLS is entirely a legacy application backwards compatibility hack
> > designed to support badly designed C applications.
> 
> TLS helps a lot on a certain register-starved architecture because you
> don't need to keep a pointer to the thread data structure around in
> case you don't need it (but called functions might). 

What's wrong with placing it on the stack? 

[Better not be anything wrong with it .. because Felix
actually does precisely that :]

-- 
John Skaller <skaller at users dot sf dot net>
Felix, successor to C++: http://felix.sf.net


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [Caml-list] Re: Thread Local Storage
  2006-02-14 22:21         ` skaller
@ 2006-03-01  7:37           ` Florian Weimer
  0 siblings, 0 replies; 7+ messages in thread
From: Florian Weimer @ 2006-03-01  7:37 UTC (permalink / raw)
  To: skaller; +Cc: caml-list

> On Tue, 2006-02-14 at 22:40 +0100, Florian Weimer wrote:
>> > TLS is entirely a legacy application backwards compatibility hack
>> > designed to support badly designed C applications.
>> 
>> TLS helps a lot on a certain register-starved architecture because you
>> don't need to keep a pointer to the thread data structure around in
>> case you don't need it (but called functions might). 
>
> What's wrong with placing it on the stack? 

Do you suggest to add an implicit argument to all function calls?
Unless you can optimize it away if it's not needed, the TLS approach
should still be faster for typical code.


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2006-03-01 11:23 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-02-13  4:29 [Caml-list] Thread Local Storage Jonathan Roewen
2006-02-13 10:05 ` Vincenzo Ciancia
2006-02-14  2:40   ` [Caml-list] " Jonathan Roewen
2006-02-14  4:06     ` skaller
2006-02-14 21:40       ` Florian Weimer
2006-02-14 22:21         ` skaller
2006-03-01  7:37           ` Florian Weimer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).