If I understand you correctly, you have two different threads (the main perl interpreter, and a C++ thread activated by an interrupt) both accessing the same perl interpreter. This is a big no-no, and corruption is going to ensue.

The basic model of perl's current threading implementation, ithreads, is that each OS-level thread is given a separate perl interpreter, so that if they run in parallel, they can't stomp on each other's data. The perl internals just aren't designed for concurrent access - there are no internal locks protecting each SV and/or critical code sections.

Dave.


In reply to Re: XS/C, threads, and calling call_sv() with a code ref by dave_the_m
in thread XS/C, threads, and calling call_sv() with a code ref by stevieb

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.