[sgen] Implement work context for thread pool threads
authorVlad Brezae <brezaevlad@gmail.com>
Thu, 15 Jun 2017 22:15:51 +0000 (01:15 +0300)
committerVlad Brezae <brezaevlad@gmail.com>
Fri, 23 Jun 2017 17:47:49 +0000 (20:47 +0300)
commit606677431ae80293e5119d302c9b3564b0a59c2b
treedd33406ea24aeb2c74eaef14264753f16803373d
parent271c88f8a8a948c5f2fd2f975895f31195906c35
[sgen] Implement work context for thread pool threads

We need to run jobs on the thread pool threads for parallel minor, parallel major, concurrent mark and concurrent sweep, some of which can run simultaneously. Instead of making separate threads reserved for each type of work, we create a work context abstraction (this contains a set of pending jobs to run and the sgen-worker callbacks). When a thread pool thread looks for work, it searches for work (jobs and idle work) through all contexts and finishes work from each one of them, from the highest to the lowest priority.

This is implemented by having different thread pool contexts (which contain the job list, work callbacks that indicate whether it should work and its ineherent priority), overall unrelated to the GC. The sgen worker infrastructure also creates separate worker contexts (which contain the object ops to be used and information about each worker, like the state and the private gray queue). We use at most two worker contexts (for minor and for major) and each worker context makes use of a sgen thread pool context.
mono/metadata/sgen-mono.c
mono/metadata/sgen-stw.c
mono/sgen/sgen-gc.c
mono/sgen/sgen-gc.h
mono/sgen/sgen-marksweep.c
mono/sgen/sgen-protocol.c
mono/sgen/sgen-simple-nursery.c
mono/sgen/sgen-thread-pool.c
mono/sgen/sgen-thread-pool.h
mono/sgen/sgen-workers.c
mono/sgen/sgen-workers.h