

![]() | Start a set with this search |
![]() | Include this search in one of my sets |
![]() | Exclude this search from one of my sets |
![]() | Permalink to these results Paste this link in email or IM: |
| Atom feed for tracking future search results Paste this URL into your reader: |
21 messages in org.ruby-lang.ruby-talkRe: C Threads and Ruby| From | Sent On | Attachments |
|---|---|---|
| Kroeger, Simon (ext) | Jun 20, 2006 3:27 am | |
| Patrick Hurley | Jun 20, 2006 4:28 am | |
| Kroeger, Simon (ext) | Jun 20, 2006 4:59 am | |
| Francis Cianfrocca | Jun 20, 2006 5:13 am | |
| Patrick Hurley | Jun 20, 2006 9:39 am | |
| Paul Brannan | Jun 20, 2006 11:33 am | |
| Patrick Hurley | Jun 20, 2006 1:16 pm | |
| Francis Cianfrocca | Jun 20, 2006 1:17 pm | |
| Francis Cianfrocca | Jun 20, 2006 1:19 pm | |
| Simon Kröger | Jun 20, 2006 2:29 pm | |
| Joel VanderWerf | Jun 20, 2006 2:35 pm | |
| Francis Cianfrocca | Jun 20, 2006 2:39 pm | |
| Bill Kelly | Jun 20, 2006 2:42 pm | |
| Simon Kröger | Jun 20, 2006 2:49 pm | |
| Francis Cianfrocca | Jun 20, 2006 3:26 pm | |
| Francis Cianfrocca | Jun 20, 2006 3:34 pm | |
| Bill Kelly | Jun 20, 2006 4:08 pm | |
| Francis Cianfrocca | Jun 20, 2006 5:07 pm | |
| Kroeger, Simon (ext) | Jun 21, 2006 2:53 am | |
| Francis Cianfrocca | Jun 21, 2006 3:15 am | |
| Paul Brannan | Jun 22, 2006 8:21 am |

![]() | Permalink for this message Paste this link in email or IM: |
![]() | Permalink for this thread Paste this link in email or IM: |
| Atom feed for this thread Paste this URL into your reader: |
| Subject: | Re: C Threads and Ruby | Actions... |
|---|---|---|
| From: | Francis Cianfrocca (garb...@gmail.com) | |
| Date: | Jun 20, 2006 1:17:49 pm | |
| List: | org.ruby-lang.ruby-talk | |
That is not true, it is completely possible to use an OS level
mutex/critical section etc, from inside a "green" Ruby thread. It will block all Ruby threads which is not very nice, but I do not know of a better solution.<<<
That's why I said you can't do it ;-). It indeed is not very nice unless you're very disciplined about how you design your synchronization sets. (And one of my pet peeves is that most people have no clue how to do this right.) Bad possibility is crummy performance. Worse yet is deadlocks, which are possible if the native code relies on something else Ruby is doing.
On 6/20/06, Patrick Hurley <phur...@gmail.com> wrote:
On 6/20/06, Francis Cianfrocca <garb...@gmail.com> wrote:
Patrick: given your proposal for an event queue filled by native threads in C and consumed by a Ruby thread, notice that there is no mutex that works between native threads and Ruby threads. Your example of "signalling" by changing the value of an integer probably works because on an Intel chip (you said you did this on Windows), it only takes one memory-bus cycle to change the value of a 32-bit integer, so you can get away without a mutex. I doubt this would work with a more complex data structure.
That is not true, it is completely possible to use an OS level mutex/critical section etc, from inside a "green" Ruby thread. It will block all Ruby threads which is not very nice, but I do not know of a better solution.
I used a system mutex (actually a CriticalSection) in both threads -- yes it blocks ruby, but only long enough to read the memory. It would be better if the Ruby C API provide a thread safe wait for non-native threads -- but this does work and is completely thread safe even if I were not doing an atomic operation (for example working off a linked list).
pth







