[CM] Fastest way to copy scheme variables into a shared buffer?

Christos Vagias chris.actondev at gmail.com
Sat Jan 22 05:50:41 PST 2022

Hi Iain,

In case you indeed want to show the current value of some scheme
object (and c-object/shared c-pointer doesn't cut it), here are some

One obvious way would be to use some mutex around any s7 operations in
both threads, and share the s7_scheme* instance in the 2. The low
level thread would acquire a lock, "print" somehow the value to
But that would have some performance impact.

Another option would be to share 2 message queues between the 2
(ideally lock-free ones) and send messages from the low thread -> you
read from the high thread, and then there you send some message to the
low level. The message sending to high->low could be
s7_object_to_c_string that if I recall correctly gives you back a
c-string that you have to free yourself : so you would free it from
the low-level thread).

On Sat, 22 Jan 2022 at 03:08, Elijah Stone <elronnd at elronnd.net> wrote:
> > I'm just wondering what the recommended way would be to store scheme
> > variables in some C memory, where the type and size is known on both
> > ends (or can be described in a notification from one to the other). Any
> > suggestions most appreciated!
> If by 'scheme variable' you mean an actual scheme-level object, I do not
> think it is possible.  If you want a scheme-level wrapper for a
> (non-scheme) object which is shared, I would use a c object.  (I think
> there are some examples in snd.)  I use s7_c_type_set_ref to set up
> accessors (viz univeral applicative syntax), which is a bit nicer than
> putting them in the global namespace.
> (And a question for Bil: any chance we can get more than a single word
>   of data for c objects?  I know there is more space in s7_cell... :)
>   -E
> _______________________________________________
> Cmdist mailing list
> Cmdist at ccrma.stanford.edu
> https://cm-mail.stanford.edu/mailman/listinfo/cmdist

More information about the Cmdist mailing list