From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id LAA15293; Fri, 30 Nov 2001 11:20:19 +0100 (MET) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id LAA15381 for ; Fri, 30 Nov 2001 11:20:18 +0100 (MET) Received: from pauillac.inria.fr (pauillac.inria.fr [128.93.11.35]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id fAUAKFn25908; Fri, 30 Nov 2001 11:20:15 +0100 (MET) Received: (from xleroy@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id LAA15366; Fri, 30 Nov 2001 11:20:15 +0100 (MET) Date: Fri, 30 Nov 2001 11:20:15 +0100 From: Xavier Leroy To: David McClain Cc: caml-list@inria.fr Subject: Re: [Caml-list] Systhreads under Win/NT Message-ID: <20011130112015.B13781@pauillac.inria.fr> References: <001401c1795d$dc43b9f0$210148bf@dylan> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Mailer: Mutt 1.0i In-Reply-To: <001401c1795d$dc43b9f0$210148bf@dylan>; from barabh@qwest.net on Thu, Nov 29, 2001 at 10:14:17PM -0700 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk > I have been trying to get a DLL running, as written in OCaml. I have been > quite successful, but along the way I had to modify the Thread.ML source to > become a delayed initialization. > Doing this allows DLL's to call caml_startup() without fear of blowing > out of the water. During DllMain() the code is only permitted restricted > capabilities, and starting up new threads is apparently not one of them. OK, I wasn't aware of this restriction. A simple workaround is to remove the creation of the "tick" thread (the one that generates context-switch events at regular intervals) from caml_startup(), and create it when the first user thread is created. There is no need to generate context-switches until at least two threads are running! I'll see what I can do about it. > -------------------------- > Finally, here is a question for the pro's who wrote the SysThreads C code... > > I understand from reading the M$ documentation that Thread Local Store is at > least 64 words long. But not guaranteed to be any larger than this. Since > your C code uses two global vars labeled as thread local, i.e., > > ----------------------------------------------------- > /* The descriptor for the currently executing thread (thread-specific) */ > > static __declspec( thread ) caml_thread_t curr_thread = NULL; > > [...other code elided...] > > /* The thread-specific variable holding last locked I/O channel */ > > static __declspec( thread ) struct channel * last_channel_locked = NULL; > > --------------------------------------------------- > ...doesn't this imply that there is a limit of 64 systhreads guaranteed in > the system? I understand this limitation as "at most 64 words of TLS *per thread*". Since we're using only 2, that should be OK, without limiting the number of threads created. > Second part of question, more of a comment, is that when DLL's are created, > manual loading via LoadLibrary() obviates the use of Thread Local storage, > as per M$ documentation. That means that one cannot use LoadLibrary() to > load a threaded OCaml DLL, as the thread storage mechanism relied upon by > the systhreads is not properly activated by the loading process. Correct. In the working sources, in order to support dynamic loading of the Systhread C code, I rewrote the __declspec(thread) variables into explicit calls to TlsGetValue and TlsSetValue, to work around this issue. - Xavier Leroy ------------------- Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr