diff options
author | Vlad Brezae <brezaevlad@gmail.com> | 2017-02-23 01:35:22 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-02-23 01:35:22 +0300 |
commit | 8fdae0685f9ba54ff85d01a7106a6dcbdd82e894 (patch) | |
tree | a450b1d25e77fbc48f6d6217f5930e033eb6d3fa | |
parent | cb947b7a56c09febb89b02b89599c003874b23f3 (diff) | |
parent | c5efaeb4988cf0d0f3ec8579d637d48e4f743b42 (diff) |
Merge pull request #4403 from BrzVlad/fix-workers-par-context
[sgen] Lock around worker start, not only finishing
-rw-r--r-- | mono/sgen/sgen-workers.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/mono/sgen/sgen-workers.c b/mono/sgen/sgen-workers.c index cc1930bcc2f..77c9413ac6c 100644 --- a/mono/sgen/sgen-workers.c +++ b/mono/sgen/sgen-workers.c @@ -330,7 +330,9 @@ marker_idle_func (void *data_untyped) if (data->private_gray_queue.num_sections > 16 && workers_finished && worker_awakenings < active_workers_num) { /* We bound the number of worker awakenings just to be sure */ worker_awakenings++; + mono_os_mutex_lock (&finished_lock); sgen_workers_ensure_awake (); + mono_os_mutex_unlock (&finished_lock); } } else { worker_try_finish (data); @@ -424,7 +426,13 @@ sgen_workers_start_all_workers (SgenObjectOperations *object_ops_nopar, SgenObje worker_awakenings = 0; mono_memory_write_barrier (); + /* + * We expect workers to start finishing only after all of them were awaken. + * Otherwise we might think that we have fewer workers and use wrong context. + */ + mono_os_mutex_lock (&finished_lock); sgen_workers_ensure_awake (); + mono_os_mutex_unlock (&finished_lock); } void |