[coop] Add mono_threads_suspend_policy_name
commit7613bbaa83ba35f036e53e8203ea88f10eae9305
authorAleksey Kliger <alklig@microsoft.com>
Tue, 3 Jul 2018 18:06:57 +0000 (3 14:06 -0400)
committerAleksey Kliger (λgeek) <akliger@gmail.com>
Fri, 6 Jul 2018 01:03:07 +0000 (5 21:03 -0400)
tree777084aac8557b62d2cfc3ddee722f564868fb6f
parent574a8fd8023b3144c691344d9dc33c5db7d8a0f4
[coop] Add mono_threads_suspend_policy_name

Returns a text description of the suspend policy currently in effect.

Also combine logic that probes for suspend policy defines and environment
variables into a single function that returns an enum value; use that to drive
the individual boolean predicate functions.

The policy is subject to configure flags from when mono was built, and the
assorted environment variables at runtime:
    MONO_ENABLE_COOPERATIVE_SUSPEND
    MONO_ENABLE_COOP
    MONO_ENABLE_HYBRID_SUSPEND
(the second one is a backward-compatible alias for the first)

The logic is:

If coop xor hybrid is enabled by configure flags, always return that policy.
Otherwise if coop and hybrid env vars are set simultaneously, it's an error.
Otherwise if MONO_ENABLE_COOP or MONO_ENABLE_COOPERATIVE_SUSPEND is set use full coop.
Otherwise if MONO_ENABLE_HYBRID_SUSPEND is set use hybrid.
Otherwise use full preemptive suspend.
mono/utils/mono-threads-coop.c
mono/utils/mono-threads-coop.h