Exemplo n.º 1
0
        public Thread(ulong isp = 0)
        {
            SystemThread = System.Threading.Thread.CurrentThread;
            Threads.Add(this);
            if (isp == 0)
            {
                _CurrentThread.Value = this;
            }
            lock (Threading)
                Id = ThreadIdIter++;

            if (isp == 0)
            {
                var(stack, stackSize) = Memory.AllocateStack();
                Stack = stack + stackSize;
                $"Stack Base: {Stack - stackSize:X}".Debug();
            }
            else
            {
                Stack = isp;
                $"Stack Top: {Stack:X}".Debug();
            }
            TlsBase = Cpu.State->TlsBase = Memory.AllocateAligned(0x10000, (0x11UL << 32) + 0x10000UL * Id);
            $"TLS Base: {TlsBase:X}".Debug();
        }