コード例 #1
0
ファイル: Thread.cs プロジェクト: Paul1nh0/Singularity
        static unsafe Thread()
        {
            threadIndexGenerator = 1;

            // Enable Thread.CurrentThread as soon as we can!
            initialThread             = Magic.toThread(BootstrapMemory.Allocate(typeof(Thread)));
            initialThread.threadState = ThreadState.Running;
            initialThread.threadIndex = 0;

            // Allocate tables for thread management
            threadTable = (Thread[])
                          BootstrapMemory.Allocate(typeof(Thread[]), maxThreads);

            // Initialize the thread and event tables
            threadTable[initialThread.threadIndex] = initialThread;
            initialThread.context = Processor.GetCurrentThreadContext();
            initialThread.context->threadIndex =
                unchecked ((ushort)initialThread.threadIndex);
            initialThread.context->UpdateAfterGC(initialThread);

            Tracing.Log(Tracing.Debug, "InitialThread={0:x8}",
                        Magic.addressOf(initialThread));
        }
コード例 #2
0
        static GC() // Class Constructor (cctor)
        {
            GC.Initialize();
            switch (gcType)
            {
#if !SINGULARITY || ADAPTIVE_COPYING_COLLECTOR
            case GCType.AdaptiveCopyingCollector: {
                AdaptiveCopyingCollector.Initialize();
                GC.installedGC = AdaptiveCopyingCollector.instance;
                break;
            }
#endif
#if !SINGULARITY || MARK_SWEEP_COLLECTOR
            case GCType.MarkSweepCollector: {
                MarkSweepCollector.Initialize();
                GC.installedGC = MarkSweepCollector.instance;
                break;
            }
#endif
#if !SINGULARITY || TABLE_MARK_SWEEP_COLLECTOR
            case GCType.TableMarkSweepCollector: {
                SimpleMarkSweepCollector.Initialize();
                GC.installedGC = SimpleMarkSweepCollector.instance;
                break;
            }
#endif
#if !SINGULARITY || SEMISPACE_COLLECTOR
            case GCType.SemispaceCollector: {
                SemispaceCollector.Initialize();
                GC.installedGC = SemispaceCollector.instance;
                break;
            }
#endif
#if !SINGULARITY || SLIDING_COLLECTOR
            case GCType.SlidingCollector: {
                SlidingCollector.Initialize();
                GC.installedGC = SlidingCollector.instance;
                break;
            }
#endif
#if !SINGULARITY || CONCURRENT_MS_COLLECTOR
            case GCType.ConcurrentMSCollector: {
                ConcurrentMSCollector.Initialize();
                GC.installedGC = ConcurrentMSCollector.instance;
                break;
            }
#endif
#if !SINGULARITY || ATOMIC_RC_COLLECTOR
            case GCType.AtomicRCCollector: {
                AtomicRCCollector.Initialize();
                GC.installedGC = AtomicRCCollector.instance;
                break;
            }
#endif
#if !SINGULARITY
            case GCType.ReferenceCountingCollector: {
                ReferenceCountingCollector.Initialize();
                GC.installedGC = ReferenceCountingCollector.instance;
                break;
            }
#endif
#if !SINGULARITY
            case GCType.DeferredReferenceCountingCollector: {
                DeferredReferenceCountingCollector.Initialize();
                GC.installedGC = DeferredReferenceCountingCollector.instance;
                break;
            }
#endif
#if !SINGULARITY || NULL_COLLECTOR
            case GCType.NullCollector: {
                VTable.Assert(wbType == 0, "No need for a write barrier");
                GC.installedGC =
                    (NullCollector)
                    BootstrapMemory.Allocate(typeof(NullCollector));
                break;
            }
#endif
#if !SINGULARITY
            case GCType.CoCoMSCollector: {
                CoCoMSCollector.Initialize();
                GC.installedGC = CoCoMSCollector.instance;
                break;
            }
#endif
            default: {
                VTable.NotReached("Unknown GC type: " + gcType);
                break;
            }
            }
            GC.installedGC.NewThreadNotification(Thread.initialThread, true);
            GC.installedGC.ThreadStartNotification(Thread.initialThread.threadIndex);
        }