Ejemplo n.º 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);
        }
Ejemplo n.º 2
0
 public KFixedPool( Kernel kernel, KPartition partition, string name, uint attributes, uint blockSize, int blockCount )
     : base(kernel, partition, name, attributes, blockSize)
 {
     Debug.Assert( blockCount > 0 );
     Debug.Assert( blockSize > 0 );
     this.BlockCount = blockCount;
 }
Ejemplo n.º 3
0
 public KFixedPool(Kernel kernel, KPartition partition, string name, uint attributes, uint blockSize, int blockCount)
     : base(kernel, partition, name, attributes, blockSize)
 {
     Debug.Assert(blockCount > 0);
     Debug.Assert(blockSize > 0);
     this.BlockCount = blockCount;
 }
Ejemplo n.º 4
0
 public KMessagePipe(Kernel kernel, KPartition partition, string name, int size)
 {
     Kernel         = kernel;
     Partition      = partition;
     Name           = name;
     Stream         = new System.IO.MemoryStream(size);
     WaitingThreads = new FastLinkedList <KThread>();
 }
Ejemplo n.º 5
0
 public KMessagePipe( Kernel kernel, KPartition partition, string name, int size )
 {
     Kernel = kernel;
     Partition = partition;
     Name = name;
     Stream = new System.IO.MemoryStream(size);
     WaitingThreads = new FastLinkedList<KThread>();
 }
Ejemplo n.º 6
0
        public KMemoryBlock(KPartition partition, uint address, uint size, bool isFree)
        {
            Partition = partition;

            Address = address;
            Size    = size;

            IsFree = isFree;
        }
Ejemplo n.º 7
0
		public KMemoryBlock( KPartition partition, uint address, uint size, bool isFree )
		{
			Partition = partition;

			Address = address;
			Size = size;

			IsFree = isFree;
		}
Ejemplo n.º 8
0
        public KPool(Kernel kernel, KPartition partition, string name, uint attributes, uint blockSize)
        {
            Debug.Assert(partition != null);
            Debug.Assert(name != null);
            Debug.Assert(blockSize > 0);

            Kernel = kernel;

            Name       = name;
            Attributes = attributes;
            BlockSize  = blockSize;
            Partition  = partition;

            Blocks     = new FastLinkedList <KMemoryBlock>();
            UsedBlocks = new FastLinkedList <KMemoryBlock>();
            FreeBlocks = new FastLinkedList <KMemoryBlock>();

            WaitingThreads = new FastLinkedList <KThread>();
        }
Ejemplo n.º 9
0
        public KPool( Kernel kernel, KPartition partition, string name, uint attributes, uint blockSize )
        {
            Debug.Assert( partition != null );
            Debug.Assert( name != null );
            Debug.Assert( blockSize > 0 );

            Kernel = kernel;

            Name = name;
            Attributes = attributes;
            BlockSize = blockSize;
            Partition = partition;

            Blocks = new FastLinkedList<KMemoryBlock>();
            UsedBlocks = new FastLinkedList<KMemoryBlock>();
            FreeBlocks = new FastLinkedList<KMemoryBlock>();

            WaitingThreads = new FastLinkedList<KThread>();
        }
Ejemplo n.º 10
0
        internal void PrintMemoryInfo()
        {
            // Partition 2 and 6 are what we care about
            StringBuilder sb = new StringBuilder();

            sb.Append("=== Memory Info ===");
            sb.Append(Environment.NewLine);
            int[] partitions = new int[] { 2, 6 };
            for (int n = 0; n < partitions.Length; n++)
            {
                KPartition partition = this.Partitions[partitions[n]];
                sb.AppendFormat("-- [{0}] -- {1:X8}-{2:X8} - {3}b/{4}b ({5}b free)", partitions[n], partition.BaseAddress, partition.UpperBound, partition.Size - partition.FreeSize, partition.Size, partition.FreeSize);
                sb.Append(Environment.NewLine);
                LinkedListEntry <KMemoryBlock> e = partition.Blocks.HeadEntry;
                while (e != null)
                {
                    KMemoryBlock block = e.Value;
                    sb.AppendFormat("   {0:X8}-{1:X8} - {2,10}b taken: {3} - {4}", block.Address, block.UpperBound, block.Size, !block.IsFree ? 1 : 0, block.Name);
                    sb.Append(Environment.NewLine);
                    e = e.Next;
                }
            }
            Debug.WriteLine(sb.ToString());
        }
Ejemplo n.º 11
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 );
        }
Ejemplo n.º 12
0
 public KVariablePool(Kernel kernel, KPartition partition, string name, uint attributes, uint blockSize)
     : base(kernel, partition, name, attributes, blockSize)
 {
 }
Ejemplo n.º 13
0
 public KVariablePool( Kernel kernel, KPartition partition, string name, uint attributes, uint blockSize )
     : base(kernel, partition, name, attributes, blockSize)
 {
 }