public void TestRemove3()
        {
            FastLinkedList <Node> list = new FastLinkedList <Node>();

            int[] values = { 1, 2, 3 };

            for (int i = 0; i < values.Length; ++i)
            {
                list.AddLastItem(new Node(values[i]));
            }

            Node node = Find(list, 1);

            list.RemoveItem(node);

            AssertValues(list, 2, 3);

            node = Find(list, 2);
            list.RemoveItem(node);

            AssertValues(list, 3);

            node = Find(list, 3);
            list.RemoveItem(node);

            AssertValues(list);
        }
示例#2
0
 private void CreateTimerQueue()
 {
     Debug.Assert( TimerQueue == null );
     TimerQueue = new TimerQueue();
     _timerCompletionQueue = new FastLinkedList<TimerCompletionEntry>();
     _timerSyncRoot = new object();
 }
示例#3
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);
        }
示例#4
0
 private void CreateTimerQueue()
 {
     Debug.Assert(TimerQueue == null);
     TimerQueue            = new TimerQueue();
     _timerCompletionQueue = new FastLinkedList <TimerCompletionEntry>();
     _timerSyncRoot        = new object();
 }
示例#5
0
 public KMessageBox(Kernel kernel, string name, int attr)
 {
     this.Kernel         = kernel;
     this.Name           = name;
     this.Attributes     = attr;
     this.Messages       = new FastLinkedList <int>();
     this.WaitingThreads = new FastLinkedList <KThread>();
 }
示例#6
0
 public KMessageBox(Kernel kernel, string name, int attr)
 {
     this.Kernel = kernel;
     this.Name = name;
     this.Attributes = attr;
     this.Messages = new FastLinkedList<int>();
     this.WaitingThreads = new FastLinkedList<KThread>();
 }
示例#7
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>();
 }
示例#8
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>();
 }
示例#9
0
        /**
         * Remove the triangles in @triangles that are completely inside the geometry contained
         * by this BSPTree instance. Triangles that are partially inside the geometry are clipped
         * against it.
         *
         * If @clipLessThan is false, the operation is reversed and triangles portions outside the geometry
         * of this BSPTree instance are removed.
         */
        public void ClipOutTriangles(FastLinkedList<Triangle> triangles, bool clipLessThan = true, IList<Triangle> discarded = null)
        {
            // ensure the root node exists
            if(root == null)return;

            // call the private, recursive version of ClipOutTriangles
            ClipOutTriangles (root, triangles, clipLessThan, discarded);
        }
示例#10
0
        public CompiledUngroupedAfaPipe_EventList(Streamable <Empty, TRegister> stream, IStreamObserver <Empty, TRegister> observer, object afa, long maxDuration)
            : base(stream, observer, afa, maxDuration, false)
        {
            this.activeStates          = new FastLinkedList <GroupedActiveState <Empty, TRegister> >();
            this.activeStatesTraverser = new FastLinkedList <GroupedActiveState <Empty, TRegister> > .ListTraverser(this.activeStates);

            this.currentList  = new List <TPayload>();
            this.lastSyncTime = -1;
        }
示例#11
0
        public KMutex(Kernel kernel, string name, uint attributes)
        {
            Kernel = kernel;

            Name       = name;
            Attributes = attributes;

            WaitingThreads = new FastLinkedList <KThread>();
        }
示例#12
0
        public KMutex( Kernel kernel, string name, uint attributes )
        {
            Kernel = kernel;

            Name = name;
            Attributes = attributes;

            WaitingThreads = new FastLinkedList<KThread>();
        }
示例#13
0
 public ListTraverser(FastLinkedList <T> list)
 {
     this.list            = list;
     this.currIndex       = 0;
     this.nextIndex       = list == null ? 0 : list.listHead;
     this.prevIndex       = 0;
     this.prevIndexIsHead = false;
     this.currIndexIsHead = true;
 }
示例#14
0
 internal ListTraverser(FastLinkedList <T> list, int hash, int currIndex, int nextIndex)
 {
     this.list            = list;
     this.prevIndex       = 0;
     this.prevIndexIsHead = false;
     this.currIndex       = currIndex;
     this.currIndexIsHead = true;
     this.nextIndex       = nextIndex;
 }
示例#15
0
 internal InvisibleTraverser(FastLinkedList <T> list)
 {
     this.list            = list;
     this.prevIndex       = 0;
     this.prevIndexIsHead = false;
     this.currIndex       = 0;
     this.currIndexIsHead = true;
     this.nextIndex       = ~list.invisibleHead;
 }
示例#16
0
 internal ListTraverser(FastLinkedList <T> list, int hash)
 {
     this.list            = list;
     this.prevIndex       = 0;
     this.prevIndexIsHead = false;
     this.currIndex       = 0;
     this.currIndexIsHead = true;
     this.nextIndex       = list.listHead;
 }
示例#17
0
        public KEvent( Kernel kernel, string name, KEventAttributes attributes, uint initialValue )
        {
            Kernel = kernel;
            Name = name;
            Attributes = attributes;
            InitialValue = initialValue;
            Value = initialValue;

            WaitingThreads = new FastLinkedList<KThread>();
        }
示例#18
0
        public KEvent(Kernel kernel, string name, KEventAttributes attributes, uint initialValue)
        {
            Kernel       = kernel;
            Name         = name;
            Attributes   = attributes;
            InitialValue = initialValue;
            Value        = initialValue;

            WaitingThreads = new FastLinkedList <KThread>();
        }
        private Node Find(FastLinkedList <Node> list, int value)
        {
            for (Node node = list.listFirst; node != null; node = node.listNext)
            {
                if (node.value == value)
                {
                    return(node);
                }
            }

            return(null);
        }
示例#20
0
        public CompiledUngroupedAfaPipe(Streamable <Empty, TRegister> stream, IStreamObserver <Empty, TRegister> observer, object afa, long maxDuration)
            : base(stream, observer, afa, maxDuration)
        {
            this.activeStates = new FastLinkedList <GroupedActiveState <Empty, TRegister> >();

            if (!this.IsSyncTimeSimultaneityFree)
            {
                this.seenEvent       = 0;
                this.tentativeOutput = new FastLinkedList <OutputEvent <Empty, TRegister> >();
                this.lastSyncTime    = -1;
            }
        }
示例#21
0
        public KSemaphore( Kernel kernel, string name, uint attributes, int initialCount, int maximumCount )
        {
            Kernel = kernel;

            Name = name;
            Attributes = attributes;

            InitialCount = initialCount;
            CurrentCount = initialCount;
            MaximumCount = maximumCount;

            WaitingThreads = new FastLinkedList<KThread>();
        }
示例#22
0
        public KSemaphore(Kernel kernel, string name, uint attributes, int initialCount, int maximumCount)
        {
            Kernel = kernel;

            Name       = name;
            Attributes = attributes;

            InitialCount = initialCount;
            CurrentCount = initialCount;
            MaximumCount = maximumCount;

            WaitingThreads = new FastLinkedList <KThread>();
        }
        private void AssertValues(FastLinkedList <Node> list, params int[] values)
        {
            Assert.AreEqual(list.size, values.Length);

            Node node = list.listFirst;

            for (int i = 0; i < values.Length; ++i)
            {
                Assert.AreEqual(node.value, values[i]);
                node = node.listNext;
            }

            Assert.IsNull(node);
        }
示例#24
0
        static void Main(string[] args)
        {
            FastLinkedList <int> list = new FastLinkedList <int>();


            Console.WriteLine(list);

            for (int k = 0; k < 20; k++)
            {
                list.Insert(k);
            }

            Console.WriteLine("nodes at level 0: " + list);
            Console.WriteLine("nodes at level 1: " + list.ToString(1));
            Console.WriteLine("nodes at level 2: " + list.ToString(2));
            Console.WriteLine("nodes at level 3: " + list.ToString(3));
            Console.WriteLine("nodes at level 4: " + list.ToString(4));
            Console.WriteLine("nodes at level 5: " + list.ToString(5));
            Console.WriteLine("nodes at level 6: " + list.ToString(6));
            Console.WriteLine("nodes at level 7: " + list.ToString(7));
            Console.WriteLine("nodes at level 8: " + list.ToString(8));
            Console.WriteLine();


            if (list.Contains(3))
            {
                Console.WriteLine("3 is in the list\n");
            }
            else
            {
                Console.WriteLine("3 is in not the list\n");
            }

            list.Delete(3);
            Console.WriteLine(list);
            Console.WriteLine("3 is deleted");

            list.Delete(0);
            Console.WriteLine(list);
            Console.WriteLine("0 is deleted");

            list.Insert(5);
            Console.WriteLine(list);
            Console.WriteLine("two 5s");
            list.Delete(5);
            Console.WriteLine(list);
            Console.WriteLine("5 is deleted");
            //PLEASE ADD MORE TEST CASES TO MAKE SURE YOUR IMPLEMENTATION WORKS!
        }
        public void TestRemove7()
        {
            FastLinkedList <Node> list = new FastLinkedList <Node>();

            int[] values = { 1, 2, 3 };

            for (int i = 0; i < values.Length; ++i)
            {
                list.AddLastItem(new Node(values[i]));
            }

            list.RemoveLastItem();

            AssertValues(list, 1, 2);
        }
示例#26
0
        /**
         * Add the triangles from @triangles into this BSPTree instance.
         */
        public void AddTriangles(List<Triangle> triangles)
        {
            if (triangles == null || triangles.Count <= 0) return;

            // ensure the root node exists
            if(root == null)
            {
                root = Node.Create(triangles[0].OrientationPlane);
            }

            // convert @triangles to a FastLinkedList structure.
            FastLinkedList<Triangle> linkedTriangles = new FastLinkedList<Triangle>();
            linkedTriangles.CopyFrom(triangles);

            // call the private, recursive version of AddTriangles
            AddTriangles(root, linkedTriangles);
        }
示例#27
0
        public KPartition( Kernel kernel, uint baseAddress, uint size )
        {
            Kernel = kernel;

            BaseAddress = baseAddress;
            Size = size;
            UpperBound = baseAddress + size;
            FreeSize = size;

            Blocks = new FastLinkedList<KMemoryBlock>();
            FreeList = new FastLinkedList<KMemoryBlock>();

            // Initial empty block
            KMemoryBlock block = new KMemoryBlock( this, baseAddress, size, true );
            Blocks.Enqueue( block );
            FreeList.Enqueue( block );
        }
        public void TestInsert13()
        {
            FastLinkedList <Node> list = new FastLinkedList <Node>();

            int[] values = { 1, 2, 3 };

            for (int i = 0; i < values.Length; ++i)
            {
                list.AddLastItem(new Node(values[i]));
            }

            Node node = new Node(4);

            list.InsertAfterItem(list.listLast, node);

            AssertValues(list, 1, 2, 3, 4);
        }
示例#29
0
        public KPartition(Kernel kernel, uint baseAddress, uint size)
        {
            Kernel = kernel;

            BaseAddress = baseAddress;
            Size        = size;
            UpperBound  = baseAddress + size;
            FreeSize    = size;

            Blocks   = new FastLinkedList <KMemoryBlock>();
            FreeList = new FastLinkedList <KMemoryBlock>();

            // Initial empty block
            KMemoryBlock block = new KMemoryBlock(this, baseAddress, size, true);

            Blocks.Enqueue(block);
            FreeList.Enqueue(block);
        }
        public void TestMix4()
        {
            FastLinkedList <Node> list = new FastLinkedList <Node>();

            int[] values = { 1, 2, 3 };

            for (int i = 0; i < values.Length; ++i)
            {
                list.AddLastItem(new Node(values[i]));
            }

            while (list.size > 0)
            {
                list.RemoveLastItem();
            }

            AssertValues(list);
        }
        public void TestRemove9()
        {
            FastLinkedList <Node> list = new FastLinkedList <Node>();

            int[] values = { 1, 2, 3 };

            for (int i = 0; i < values.Length; ++i)
            {
                list.AddLastItem(new Node(values[i]));
            }

            Node node = Find(list, 2);

            list.RemoveItem(node);

            Assert.IsNull(node.listPrev);
            Assert.IsNull(node.listNext);
        }
        public void TestInsert10()
        {
            FastLinkedList <Node> list = new FastLinkedList <Node>();

            int[] values = { 1, 2, 3 };

            for (int i = 0; i < values.Length; ++i)
            {
                list.AddLastItem(new Node(values[i]));
            }

            Node insertNode = Find(list, 3);

            Node node = new Node(4);

            list.InsertBeforeItem(insertNode, node);

            AssertValues(list, 1, 2, 4, 3);
        }
        public void TestAddLast()
        {
            FastLinkedList <Node> list = new FastLinkedList <Node>();

            Node node = new Node(1);

            list.AddLastItem(node);

            Assert.AreEqual(list.size, 1);

            Assert.AreEqual(list.listFirst, node);
            Assert.AreEqual(list.listLast, node);

            Assert.IsNull(list.listFirst.listPrev);
            Assert.IsNull(list.listFirst.listNext);

            Assert.IsNull(list.listLast.listPrev);
            Assert.IsNull(list.listLast.listNext);
        }
示例#34
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>();
        }
示例#35
0
        private static void BetterListTest()
        {
            FastLinkedList <int> list = new FastLinkedList <int>(1);

            long sum = 0;

            for (int i = 1; i <= 10000; i++)
            {
                sum += i;
                list.Insert(i);
            }

            /*for (int i = 1; i <= 10000; i+=10)
             * {
             *  list.Remove(i);
             *  sum -= i;
             * }*/

            Random r   = new Random(0);
            int    cnt = 1;

            while (cnt < 10000)
            {
                cnt += r.Next(1, 5);
                list.Remove(cnt);
                list.Remove(cnt);
                sum -= cnt;
            }

            FastLinkedList <int> .ListTraverser iter = new FastLinkedList <int> .ListTraverser(list);

            iter.Reset();

            long check = 0;

            while (iter.Next(out int index))
            {
                check += list.Values[index];
            }
            Assert.IsTrue(sum == check);
        }
示例#36
0
        public override void Start()
        {
            _device = _kernel.Emulator.Input;
            if (_device == null)
            {
                return;
            }

            _buffer         = new FastLinkedList <Sample>();
            _bufferEvent    = new AutoResetEvent(false);
            _bufferSyncRoot = new object();

            _timer = _kernel.TimerQueue.CreatePeriodicTimer(
                new TimerCallback(this.PollCallback),
#if THREADED
                5,
#else
                25,
#endif
                TimerExecutionContext.TimerThread, false);
        }
示例#37
0
        // manual add
        public void sceKernelExitGameWithStatus(int status)
        {
            Log.WriteLine(Verbosity.Normal, Feature.Bios, "sceKernelExitGameWithStatus: exiting with status code {0}", status);

            // Call exit callbacks
            FastLinkedList <KCallback> cbll = _kernel.Callbacks[Kernel.CallbackTypes.Exit];

            if (cbll.Count > 0)
            {
                LinkedListEntry <KCallback> cbs = cbll.HeadEntry;
                while (cbs != null)
                {
                    _kernel.NotifyCallback(cbs.Value, ( uint )status);
                    cbs = cbs.Next;
                }
            }
            else
            {
                // Do the callbacks kill the game for us?
                _kernel.StopGame(status);
            }
        }
        public void TestAdd4()
        {
            FastLinkedList <Node> list = new FastLinkedList <Node>();

            int[] values = { 1, 2, 3 };

            for (int i = 0; i < values.Length; ++i)
            {
                list.AddFirstItem(new Node(values[i]));
            }

            Assert.AreEqual(list.size, 3);

            Node node = list.listLast;

            for (int i = 0; i < values.Length; ++i)
            {
                Assert.AreEqual(values[i], node.value);
                node = node.listPrev;
            }

            Assert.IsNull(node);
        }
示例#39
0
        public Kernel(Bios bios)
        {
            Debug.Assert(bios != null);
            Bios     = bios;
            Emulator = Bios.Emulator;

            Debug.Assert(Emulator.Cpu != null);
            Cpu          = Emulator.Cpu;
            CpuCore      = Cpu.Cores[0];
            Memory       = Cpu.Memory;
            MemorySystem = Memory.MemorySystem;

            Devices = new List <KDevice>();

            UserModules = new List <KModule>(10);

            Threads            = new List <KThread>(128);
            SchedulableThreads = new FastLinkedList <KThread>();

            Handles  = new Dictionary <uint, KHandle>();
            _lastUid = 100;

            SpeedLocked = true;
        }
示例#40
0
        public override void Start()
        {
            _device = _kernel.Emulator.Input;
            if( _device == null )
                return;

            _buffer = new FastLinkedList<Sample>();
            _bufferEvent = new AutoResetEvent( false );
            _bufferSyncRoot = new object();

            _timer = _kernel.TimerQueue.CreatePeriodicTimer(
                new TimerCallback( this.PollCallback ),
            #if THREADED
                5,
            #else
             25,
            #endif
             TimerExecutionContext.TimerThread, false );
        }
示例#41
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>();
        }
示例#42
0
 public MGLTextureCache( MGLDriver driver, MGLContext ctx )
 {
     _driver = driver;
     _ctx = ctx;
     _values = new FastLinkedList<MGLTexture>();
 }
示例#43
0
        /**
         * Recursive version of ClipOutTriangles. This method partitions the triangles
         * in @triangles using @node's split plane, and then recursively calls itself
         * with the resulting greater-than and less-than lists. If the recursion reaches a
         * point where triangles in @triangles are on the back side of @node's split plane,
         * but this instance of BSPTree contains no geometry on that side (node.LessThan == null),
         * then the triangles placed in @lessThan are deleted from @triangles. This removes
         * the portions of triangles in @triangles that lie inside the geometry of this BSPTree
         * instance.
         *
         * If @clippLessThan is false, then we perform the reverse of the above oepration.
         * Triangles placed in @greaterThan than are removed when node.GreaterThan == null.
         * In that case the portions of triangles in @triangles that lie outside the geometry
         * of this BSPTree instance are removed.
         */
        private void ClipOutTriangles(Node node, FastLinkedList<Triangle> triangles, bool clipLessThan = true, IList<Triangle> discarded = null)
        {
            if (triangles == null || triangles.First == null)return;
            if(node == null)return;

            FastLinkedList<Triangle> lessThan = new FastLinkedList<Triangle>();
            FastLinkedList<Triangle> greaterThan = new FastLinkedList<Triangle>();

            // iterate through each triangle in @triangles and classify/partition each according
            // @node's split plane. triangles on the front side go into @greaterThan, triangles
            // on the back side go into @lessThan. co-planar triangles whose normal matches that of
            // @node's split plane go into @greaterThan; the rest go into @lessThan.
            triangles.Iterate((Triangle tri) => {
                Partitioner.Orientation orient = Partitioner.SliceTriangle(tri, node.SplitPlane, lessThan, greaterThan, lessThan, greaterThan);
            });

            // release memory used by @triangles
            triangles.Clear();

            // recurse on the back side of @node's split plane if this BSPTree contains
            // geometry on that side. if it does not, and we want to clip out triangles
            // inside this BSPTree's geometry (@clipLessThan == true), then we clear out @lessThan.
            if(node.LessThan != null)
                ClipOutTriangles (node.LessThan, lessThan, clipLessThan, discarded);
            else if(clipLessThan)
            {
                if(discarded != null)lessThan.CopyInto(discarded);
                lessThan.Clear();
            }

            // recurse on the front side of @node's split plane if this BSPTree contains
            // geometry on that side. if it does not, and we want to clip out triangles
            // outside this BSPTree's geometry (@clipLessThan == false), then we clear out @greaterThan.
            if(node.GreaterThan != null)
                ClipOutTriangles (node.GreaterThan, greaterThan, clipLessThan, discarded);
            else if(!clipLessThan)
            {
                if(discarded != null)greaterThan.CopyInto(discarded);
                greaterThan.Clear();
            }

            // rebuild @triangles with the properly clipped triangles
            triangles.AppendIntoList(lessThan);
            triangles.AppendIntoList(greaterThan);
        }
示例#44
0
 private Node()
 {
     LessThan = null;
     GreaterThan = null;
     triangles = new FastLinkedList<Triangle>();
 }
示例#45
0
        /// <summary>
        /// Initialize a new <see cref="TimerQueue"/> instance.
        /// </summary>
        public TimerQueue()
        {
            _timers = new FastLinkedList<Timer>();
            _timerId = 0;
            _syncRoot = new object();
            _delegate = new WaitOrTimerDelegate( this.Callback );
            GC.KeepAlive( _delegate );

            _hQueue = NativeMethods.CreateTimerQueue();
            Debug.Assert( _hQueue != IntPtr.Zero );
            if( _hQueue == IntPtr.Zero )
            {
                int error = Marshal.GetLastWin32Error();
                throw new Win32Exception( error, "Unable to create timer queue." );
            }
        }
示例#46
0
        /**
         * Rescursive version of AddTriangles. This method partitions the triangles
         * in @triangles using @node's split plane, and then recursively calls itself
         * with the resulting greater-than and less-than lists.
         */
        private void AddTriangles(Node node, FastLinkedList<Triangle> triangles)
        {
            if (triangles == null)return;
            if(node == null)return;

            // get a reference to the list of triangles that are co-planar with
            // @node's split plane
            FastLinkedList<Triangle> nodeTriangles =  node.GetTriangleList();

            FastLinkedList<Triangle> lessThan = new FastLinkedList<Triangle> ();
            FastLinkedList<Triangle> greaterThan = new FastLinkedList<Triangle> ();

            // iterate through each triangle in @triangles and classify/partition each according
            // @node's split plane. co-planar triangles go into @nodeTriangles, triangles on the front
            // side go into @greaterThan, traingles on the back side go into @lessThan.
            triangles.Iterate((Triangle tri) => {
                Partitioner.Orientation orient = Partitioner.SliceTriangle(tri, node.SplitPlane, lessThan, greaterThan, nodeTriangles, nodeTriangles);
            });

            // release clear memory occupied by @triangles
            triangles.Clear();

            // recurse on the back side of @node's split plane
            if(lessThan.First != null)
            {
                if(node.LessThan == null)
                    node.LessThan = Node.Create(lessThan.First.Value.OrientationPlane);
                AddTriangles(node.LessThan, lessThan);
            }

            // recurse on the front side of @node's split plane
            if(greaterThan.First != null)
            {
                if( node.GreaterThan == null)
                    node.GreaterThan = Node.Create(greaterThan.First.Value.OrientationPlane);
                AddTriangles(node.GreaterThan,  greaterThan);
            }
        }
示例#47
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 );
        }