Re: [Gc] GC and Coroutines in multiple threads
Ivan Maidanski <ivmai-JGs/[email protected]> Wed, 23 Sep 2015 11:22:15 +0300
| Newsgroups | gmane.comp.programming.garbage-collection.boehmgc |
|---|---|
| Message-ID | <[email protected]> |
My current understanding is that fiber/coroutine is similar to regular thread except that we are in do-blocking state for all except current fiber. It is better to propose high level api for fibers like register/unregister/switchTo or even intercept system fiber api like we did for regular threads. ---- вторник, 22 сентября 2015г., 06:24 +03:00 от "Juan Wajnerman" < [email protected]> : >Long time ago, I opened a discussion about using the GC with coroutines (using libpcl): https://lists.opendylan.org/pipermail/bdwgc/2014-January/005819.html > >Eventually I solved the problem, by setting GC_stackbottom to the right value before jumping to a different coroutine, and then making sure all coroutine stacks are visited during GC. The code is in Crystal language but I think it’s easy to understand even if you don’t know the language: https://github.com/manastech/crystal/blob/master/src/fiber/fiber.cr > >This works perfectly fine as long as a single thread is used, but now we want to to take this to the next level and have coroutines in multiple threads. > >As far as I understand, GC_stackbottom only serves for the main thread. For other threads, this value is stored in GC_thread.stack_end. However this is not part of the public API. The only public function that can actually make changes to this value seems to be GC_call_with_gc_active. However, this is not useful for coroutines, because I need to set back the value once the coroutine is resumed, so this doesn’t work with the callback style that this API have to offer. > >Do you think it’s possible to add some public API to expose this functionality? I could work on this and send a PR. For example, adding a function like: GC_set_current_thread_stack_end(ptr_t). > >Best regards! >- Juan > >_______________________________________________ >bdwgc mailing list >[email protected] >https://lists.opendylan.org/mailman/listinfo/bdwgc _______________________________________________ bdwgc mailing list [email protected] https://lists.opendylan.org/mailman/listinfo/bdwgc