mirror of
https://github.com/RGBCube/serenity
synced 2025-06-10 08:32:08 +00:00

The scheduler now operates on threads, rather than on processes. Each process has a main thread, and can have any number of additional threads. The process exits when the main thread exits. This patch doesn't actually spawn any additional threads, it merely does all the plumbing needed to make it possible. :^)
42 lines
1.1 KiB
C++
42 lines
1.1 KiB
C++
#include "DiskDevice.h"
|
|
|
|
DiskDevice::DiskDevice()
|
|
{
|
|
}
|
|
|
|
DiskDevice::~DiskDevice()
|
|
{
|
|
}
|
|
|
|
bool DiskDevice::read(DiskOffset offset, unsigned length, byte* out) const
|
|
{
|
|
ASSERT((offset % block_size()) == 0);
|
|
ASSERT((length % block_size()) == 0);
|
|
dword first_block = offset / block_size();
|
|
dword end_block = (offset + length) / block_size();
|
|
byte* outptr = out;
|
|
for (unsigned bi = first_block; bi < end_block; ++bi) {
|
|
if (!read_block(bi, outptr))
|
|
return false;
|
|
outptr += block_size();
|
|
}
|
|
return true;
|
|
}
|
|
|
|
bool DiskDevice::write(DiskOffset offset, unsigned length, const byte* in)
|
|
{
|
|
ASSERT((offset % block_size()) == 0);
|
|
ASSERT((length % block_size()) == 0);
|
|
dword first_block = offset / block_size();
|
|
dword end_block = (offset + length) / block_size();
|
|
ASSERT(first_block <= 0xffffffff);
|
|
ASSERT(end_block <= 0xffffffff);
|
|
const byte* inptr = in;
|
|
for (unsigned bi = first_block; bi < end_block; ++bi) {
|
|
if (!write_block(bi, inptr))
|
|
return false;
|
|
inptr += block_size();
|
|
}
|
|
return true;
|
|
}
|
|
|