"…each thread gets its own data”

That is probably the obvious.

”…they exchange ownership of the whole structure via passing a pointer through a pipe"

Any links to instructive examples are gladly accepted.

Links for thread victims:

Update: Perhaps a solution?

Update 2: …seems to be incomplete…last update 10 years ago or so

#include <dispatch/dispatch.h> #include <err.h> #include <stdio.h> #include <stdlib.h> int main(void) { dispatch_queue_t gizmo; dispatch_time_t wait; gizmo = dispatch_get_main_queue(); wait = dispatch_time(DISPATCH_TIME_NOW, 1LL * NSEC_PER_SEC); dispatch_after(wait, gizmo, ^{ printf("Super Karl\n"); exit(0); }); dispatch_main(); return (0); } /* scons: Reading SConscript files ... */ /* scons: done reading SConscript files. */ /* scons: Building targets ... */ /* clang -pthread -g -fsanitize=address -fsanitize=undefined -fsanitiz +e=float-divide-by-zero -fb\ locks -o containers/obj/gcd.o -c -std=c17 -O3 -Wall -I_include -Iconta +iners/include -Iinclude co\ ntainers/src/gcd.c */ /* clang -pthread -g -fsanitize=address -fsanitize=undefined -fsanitiz +e=float-divide-by-zero -fb\ locks -o containers/bin/gcd -Wl -fuse-ld=lld containers/obj/gcd.o -lBl +ocksRuntime -ldispatch */ /* scons: done building targets. */ /* karl@rantanplan:~/src/myC/testomato$ containers/bin/gcd */ /* Super Karl */

libdispatch tutorial


In reply to Re^8: OT: Why does malloc always give me 24? by karlgoethebier
in thread OT: Why does malloc always give me 24? [SOLVED] by karlgoethebier

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.