Пример #1
0
        public KThread(Kernel kernel, KModule module, KPartition partition, string name, uint entryAddress, int priority, KThreadAttributes attributes, uint stackSize)
        {
            Debug.Assert(partition != null);

            Kernel = kernel;

            Name            = name;
            EntryAddress    = entryAddress;
            InitialPriority = priority;
            Priority        = priority;
            Attributes      = attributes;
            Module          = module;

            State = KThreadState.Stopped;

            ExitWaiters       = new FastLinkedList <KThread>();
            NotifiedCallbacks = new FastLinkedList <KCallback>();

            //if( stackSize < 65535 )
            //{
            //    Log.WriteLine( Verbosity.Normal, Feature.Bios, "KThread: attempt to allocate thread with a stack of {0} - forcing up to the minimum of 64K", stackSize );
            //    stackSize = 65535;
            //}

            RunClocks = 0;
            InterruptPreemptionCount = 0;
            ThreadPreemptionCount    = 0;

            Partition  = partition;
            StackBlock = partition.Allocate(string.Format("Thread '{0}' Stack", name), KAllocType.High, 0, stackSize);
            Debug.Assert(StackBlock != null);
            TlsBlock = partition.Allocate(string.Format("Thread '{0}' TLS", name), KAllocType.High, 0, 0x4000);                 // 16k of thread local storage --- enough?
            Debug.Assert(TlsBlock != null);
        }
Пример #2
0
        public KThread( Kernel kernel, KModule module, KPartition partition, string name, uint entryAddress, int priority, KThreadAttributes attributes, uint stackSize )
        {
            Debug.Assert( partition != null );

            Kernel = kernel;

            Name = name;
            EntryAddress = entryAddress;
            InitialPriority = priority;
            Priority = priority;
            Attributes = attributes;
            Module = module;

            State = KThreadState.Stopped;

            ExitWaiters = new FastLinkedList<KThread>();
            NotifiedCallbacks = new FastLinkedList<KCallback>();

            //if( stackSize < 65535 )
            //{
            //    Log.WriteLine( Verbosity.Normal, Feature.Bios, "KThread: attempt to allocate thread with a stack of {0} - forcing up to the minimum of 64K", stackSize );
            //    stackSize = 65535;
            //}

            RunClocks = 0;
            InterruptPreemptionCount = 0;
            ThreadPreemptionCount = 0;

            Partition = partition;
            StackBlock = partition.Allocate( string.Format( "Thread '{0}' Stack", name ), KAllocType.High, 0, stackSize );
            Debug.Assert( StackBlock != null );
            TlsBlock = partition.Allocate( string.Format( "Thread '{0}' TLS", name ), KAllocType.High, 0, 0x4000 ); // 16k of thread local storage --- enough?
            Debug.Assert( TlsBlock != null );
        }