Re: [Gc] Is GC_ALWAYS_MULTITHREADED safe with single-th readed case

Ivan Maidanski <ivmai-JGs/[email protected]> Sat, 21 Jun 2014 20:46:06 +0400
Newsgroups gmane.comp.programming.garbage-collection.boehmgc
Message-ID <[email protected]>
 Hi Stefan,

This macro just makes locking unconditional thus eliminating 1 conditional jump in LOCK and UNLOCK used by GC internally. As a consequence, if you for the time while you have only 1 thread, it does unneeded LOCK/UNLOCK. So, it is safe to define even you have single thread.

Of course, on modern CPUs I guess this macro saves 1 CPU cycle or less (plus it saves some code, e.g. 2 KiB of gctest.exe). The real cause of adding this macro was for static code analysis (regarding locks).

Regards,
Ivan


Sat, 21 Jun 2014 11:37:30 +0200 from Stefan Kral <[email protected]>:
>Hello everyone.
>
>My multi-threaded application remains single-threaded for some time after starting up. The first few collections are likely to occur while single-threaded.
>
>I wonder if it is safe for me to define GC_ALWAYS_MULTITHREADED when building the GC.
>
>Also, I am curious to know if using the #define saves some CPU cycles---compared to calling GC_allow_register_threads after initializing the GC.
>
>Best Regards,
>Stefan.
>
>_______________________________________________
>bdwgc mailing list
>[email protected]
>https://lists.opendylan.org/mailman/listinfo/bdwgc

_______________________________________________
bdwgc mailing list
[email protected]
https://lists.opendylan.org/mailman/listinfo/bdwgc