public bool Free(int address) { LinkedListEntry <KMemoryBlock> e = UsedBlocks.HeadEntry; while (e != null) { if (e.Value.Address == address) { UsedBlocks.Remove(e); FreeBlocks.Enqueue(e.Value); return(this.WakeWaiter()); } e = e.Next; } return(false); }
private void TimerCallback(Timer timer) { KernelTimerCallback realCallback = ( KernelTimerCallback )(( object[] )timer.State)[0]; object realState = (( object[] )timer.State)[1]; lock (_timerSyncRoot) _timerCompletionQueue.Enqueue(new TimerCompletionEntry(timer, realCallback, realState)); this.Cpu.BreakExecution(); }
private void AddToFreeList(KMemoryBlock block) { // Inserts in to free list at the right place if (FreeList.Count == 0) { FreeList.Enqueue(block); } else { LinkedListEntry <KMemoryBlock> e = FreeList.HeadEntry; while (e != null) { if (e.Value.Address > block.Address) { // Found next block - insert before FreeList.InsertBefore(block, e); return; } e = e.Next; } // Didn't find - add to tail FreeList.Enqueue(block); } }
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 KMemoryBlock Allocate() { if (FreeBlocks.Count == 0) { bool allocated = this.AllocateBlocks(); // Allocation will fail if we are fixed and out of blocks! if (allocated == false) { return(null); } Debug.Assert(FreeBlocks.Count > 0); } KMemoryBlock block = FreeBlocks.Dequeue(); UsedBlocks.Enqueue(block); return(block); }
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); }
private void PollCallback(Timer timer) { Sample sample; lock ( _bufferSyncRoot ) { sample = this.GetSample(); _buffer.Dequeue(); _buffer.Enqueue(sample); } _bufferEvent.Set(); uint oldPressed = _pressedButtons; _pressedButtons = ( uint )sample.Buttons; uint stillPressed = _pressedButtons & oldPressed; _releasedButtons = ~_pressedButtons; _makedButtons = _pressedButtons & ~stillPressed; _breakedButtons = oldPressed & ~stillPressed; }