chicken-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Chicken-users] Best way to share memory between C and Chicken


From: Dan Leslie
Subject: Re: [Chicken-users] Best way to share memory between C and Chicken
Date: Sat, 04 May 2013 16:29:34 -0700
User-agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:17.0) Gecko/20130328 Thunderbird/17.0.5

With semaphores and shared memory you can basically emulate the behaviour you would expect from native threads. Though I'm not certain about how comparable it is in performance, I understand it to be quite zippy.

Ie, shm_open will give you a file descriptor, which you can then treat as a memory buffer by using mmap, and using semaphores you can safely signal across processes whether someone is in a critical section or not.

To me, the drawback is in that creating a shared memory object and wrapping it in mmap is clunkier than just sharing all in-process memory with a bunch of native threads. But the upshot is that it can be a lot safer in practice, especially when you have many hands in the pot and not much rigor is being taken towards thread safety.

Regarding Chicken threads, as far as I'm aware SRFI-18 threads in Chicken are 'green', in that they run on a single native thread and cannot avail themselves of additional native threads.

You mention that you've been poking at native threads for a while. Do you have a native thread implementation that could be packaged up as an egg? I think some people would be eager to try it out, even if its incomplete. Maybe this would be a good opportunity to get used to Git via a GitHub project? ;)

Thanks,
-Dan



reply via email to

[Prev in Thread] Current Thread [Next in Thread]