Announcement

Collapse
No announcement yet.

How is Threaded implemented?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • How is Threaded implemented?

    Hi,
    I'm not sure if I put this question in the right forum, but here we go...

    First of all I've been wondering how a THREADED variable is different from a global variable + critical sections? I've done a simple threaded test with a test-exe starting threads and there seems to be no performance loss.
    But still, what other way is there?


    Second, I'm mostly building for the web (using isapi extensions) so in my case I always have multi-threaded apps. But with the new version, I want to get global memory 'over' all isolated worker threads (in IIS). What I found is that - since the IIS worker threads are isolated - they do NOT share memory from the isapi (eg a DLL using global variables) between one another.
    Has someone does this before or point me in right direction?

    Many regards
    Jeroen Brouwers

  • #2
    A THREADED variable does not require the use of a synchronization object such as a critical section because there is, in essence, a separate copy of the variable for each thread of execution.

    While the actual implementation is proprietary, it functions the same as does the Windows Thread Local Storage feature, demo'd here:
    Terminate Worker Threads Using Windows Events (and Using Thread Local Storage) Demo Dec 23 2005

    Logically, a THREADED scalar or dynamic string variable works as though it were a single-dimension array, with one element for each current thread of execution, and the compiler redimensioning and finding the correct subscript with no programming required by you depending on the current thread context. A THREADED array behaves as though there were an extra dimension, with one element per current thread of execution.

    I can't help you with IIS because I don't know squat about it.


    MCM
    Michael Mattias
    Tal Systems Inc. (retired)
    Racine WI USA
    [email protected]
    http://www.talsystems.com

    Comment

    Working...
    X