mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-06-11 02:13:56 +09:00

FileHandle gets a hasDataAvailableForRead() getter. If this returns true in sys$read(), the task will block(BlockedRead) + yield. The fd blocked on is stored in Task::m_fdBlockedOnRead. The scheduler then looks at the state of that fd during the unblock phase. This makes "sh" restful. :^) There's still some problem with the kernel not surviving the colonel task getting scheduled. I need to figure that out and fix it.
34 lines
610 B
C++
34 lines
610 B
C++
#include "FullDevice.h"
|
|
#include "Limits.h"
|
|
#include "sys-errno.h"
|
|
#include <AK/StdLib.h>
|
|
#include <AK/kstdio.h>
|
|
|
|
FullDevice::FullDevice()
|
|
{
|
|
}
|
|
|
|
FullDevice::~FullDevice()
|
|
{
|
|
}
|
|
|
|
bool FullDevice::hasDataAvailableForRead() const
|
|
{
|
|
return true;
|
|
}
|
|
|
|
Unix::ssize_t FullDevice::read(byte* buffer, Unix::size_t bufferSize)
|
|
{
|
|
kprintf("FullDevice: read from full\n");
|
|
Unix::size_t count = min(GoodBufferSize, bufferSize);
|
|
memset(buffer, 0, count);
|
|
return count;
|
|
}
|
|
|
|
Unix::ssize_t FullDevice::write(const byte*, Unix::size_t bufferSize)
|
|
{
|
|
if (bufferSize == 0)
|
|
return 0;
|
|
return -ENOSPC;
|
|
}
|
|
|