This is the mail archive of the cygwin@sourceware.cygnus.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

RE: BAD NEWS - Apache 1.2b10 on NT


Giovanni Maruzzelli[SMTP:maruzz@matrice.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@bird.fu.is.saga-u.ac.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@cygnus.com" with one line of text: "help".


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]