From: colin AT bird DOT fu DOT is DOT saga-u DOT ac DOT jp (Colin Peters) Subject: RE: BAD NEWS - Apache 1.2b10 on NT 15 May 1997 23:36:53 -0700 Sender: mail AT cygnus DOT com Approved: cygnus DOT gnu-win32 AT cygnus DOT com Distribution: cygnus Message-ID: <01BC6208.5EF05380.cygnus.gnu-win32@gbird0> Original-To: "'Giovanni Maruzzelli'" Original-Cc: "'GNU-Win32'" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Original-Sender: owner-gnu-win32 AT cygnus DOT com Giovanni Maruzzelli[SMTP:maruzz AT matrice DOT it] wrote: >2) if you connect from two machine at the same time it crash > >I think the problem is that all threads share the same memory, so, if they >try to modify at the same time, they crash. >I'vealso utilized a lot of Mutex, but this don't help. > >There's no mean to have memory storage space reserved for a thread. It probably won't make your problems go away but there *are* ways of reserving memory space on a per-thread basis using the Win32 API. Unfortunately the use of these functions will probably require massive changes to the overall form of the server threads... which probably won't be worth it to you... Anyway you can look in the book Advanced Windows by Jeffery Richter (Microsoft Press), chapter 12 "Thread Local Storage" or look at the Win32 API documents for TlsAlloc, TlsFree, TlsSetValue and TlsGetValue. Basically the main program allocates a thread local index using TlsAlloc. Then the multi thread code sets the value associated with this index using TlsSetValue (for example to point to a block of memory holding thread local data), probably right at the start of the new thread. Whenever any function uses TlsGetValue to obtain the value associated with the index (put it in a static variable so that all threads can see it) it sees the value associated with the current thread, and each thread gets its own value. If GCC supported the __declspec(thread) syntax (or some equivalent) then you could simply mark all your thread local "static" or "global" variables with that and everything would be simpler, but I don't think that is likely to work now or anytime soon. If the problem is caused by data that really is supposed to be shared then I suggest you keep looking at your mutexes and critical sections, because it should be possible to make things work that way. Note that the default process heap is serialized, so it should be safe to call malloc or, failing that, HeapAlloc, from within threads. Anyway, just wanted to clear that up (or is that make it even muddier? :) ). Colin. -- Colin Peters - colin AT bird DOT fu DOT is DOT saga-u DOT ac DOT jp -- Saga University Dept. of Information Science -- http://www.fu.is.saga-u.ac.jp/~colin/index.html -- http://www.geocities.com/Tokyo/Towers/6162/ - For help on using this list (especially unsubscribing), send a message to "gnu-win32-request AT cygnus DOT com" with one line of text: "help".