Time to bring out one of my favourite computing quotes once again (and it's more applicable than the last time I did :-):

A computer is a state machine. Threads are for people who can't program state machines. - Alan Cox

Processors handle commands sequentially, it is impossible for any currently existing CPU core to handle two instructions at the same time (well, this is not strictly true for SMT processors, but things get hairy enough here to ignore that for this discussion). Thus, the number of operations that can theoretically be executed at exactly the same time on your machine will be limited by the number of CPU cores on that same machine. Even then, synchronising several processes to execute exactly the same command at the same time on different cores is a hard task and likely not possible without reaching into your OS kernel (in fact, I'd be surprised if it were possible on a non-RT OS at all). Now, if (as indicated in your post) you are using "date" to confirm the processes are running at the same time this probably means you don't actually need them to run at the exact same microsecond but have a certain leeway. You'd need to tell us what you're actually trying to do and what kind of delay in execution is acceptable before we can make any sensible suggestions. If, for example, the task is non-blocking (i.e. does not involve IO) and quick, simple sequential processing in a loop may be sufficient.


All dogma is stupid.

In reply to Re: multi threading by tirwhan
in thread multi threading by mude

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.