Hello Neighbour,

For some reason I cannot reply directly to your last message. Here is the html that would run my code:

<html> <head> <script type="text/javascript" src="http://localhost/jquery-1.6.1.min. +js"></script> <script> function init() { var options = { type: "POST", url: "http://localhost/testSharing", }; for(var i = 0; i < 100; i++) $.ajax(options); } $(document).ready(init); </script> </head> <body> </body> </html>

This is assuming that you place your jquery source at the root (the file is named jquery-1.6.1.min.js). You can download jquery from http://jquery.com/. I am not sure what the package is that you installed. Javascript files are simple text files with code that you can place directly in your document root.

Also don't forget to update your apache2.conf file with the <IfModule mpm_worker_module> etc. This will force Apache to process requests in a single process, which you should see when you look at the log file outputted by the handler. There should only be one number in the process ID field.

Pressing F5 with your finger is simply not fast enough, which is why we need the javascript code to pound the server with several requests simultaneously so that we force it to use at least two threads at the same time. That's why you also need to pay attention to the output in the log file I created. The process ID should be the same (threads::shared cannot share a variable across processes; testing it across multiple process does not make sense). Then, you should see different thread IDs as well. Ideally, there is only one Initializing statement even if several threads access the shared variable. My problem is that I get multiple Initializing statements even when all requests are processed in one process and multiple threads answer. Note that during my testing I had cases where some new threads did not output Initializing... but others did. So it looked to me like the sharing of the variable worked sometimes and other times it did not. I would like to understand why.

Anyway, I am excited to hear whether you can reproduce my results as well. Don't forget to update apache2.conf and let me know how the javascript works for you.

Sincerely,

Pawel


In reply to Re^4: Threaded MPM Sharing Variables (this time with complete test code) by busymeister
in thread Threaded MPM Sharing Variables (this time with complete test code) by busymeister

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.