示例#1
0
        public void Write(long posBy4Kbs, int numberOf4Kbs, byte *source)
        {
            const int pageSizeTo4KbRatio = (Constants.Storage.PageSize / (4 * Constants.Size.Kilobyte));
            var       pageNumber         = posBy4Kbs / pageSizeTo4KbRatio;
            var       offsetBy4Kb        = posBy4Kbs % pageSizeTo4KbRatio;
            var       numberOfPages      = numberOf4Kbs / pageSizeTo4KbRatio;

            if (numberOf4Kbs % pageSizeTo4KbRatio != 0)
            {
                numberOfPages++;
            }

            var newPagerState = _abstractPager.EnsureContinuous(pageNumber, numberOfPages);

            if (newPagerState != null)
            {
                _pagerState.Release();
                newPagerState.AddRef();
                _pagerState = newPagerState;
            }

            var   toWrite     = numberOf4Kbs * 4 * Constants.Size.Kilobyte;
            byte *destination = _abstractPager.AcquirePagePointer(null, pageNumber, _pagerState)
                                + (offsetBy4Kb * 4 * Constants.Size.Kilobyte);

            _abstractPager.UnprotectPageRange(destination, (ulong)toWrite);

            Memory.Copy(destination, source, toWrite);

            _abstractPager.ProtectPageRange(destination, (ulong)toWrite);
        }
示例#2
0
        public void Write(long pageNumber, int numberOfPages, byte *source)
        {
            var newPagerState = _abstractPager.EnsureContinuous(pageNumber, numberOfPages);

            if (newPagerState != null)
            {
                _pagerState.Release();
                newPagerState.AddRef();
                _pagerState = newPagerState;
            }

            var   toWrite     = numberOfPages * _abstractPager.PageSize;
            byte *destination = _abstractPager.AcquirePagePointer(null, pageNumber, _pagerState);

            _abstractPager.UnprotectPageRange(destination, (ulong)toWrite);

            Memory.BulkCopy(destination, source, toWrite);

            _abstractPager.ProtectPageRange(destination, (ulong)toWrite);
        }