mirror of
https://github.com/RGBCube/serenity
synced 2025-05-17 22:25:08 +00: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.
29 lines
458 B
C++
29 lines
458 B
C++
#include "NullDevice.h"
|
|
#include "Limits.h"
|
|
#include <AK/StdLib.h>
|
|
#include <AK/kstdio.h>
|
|
|
|
NullDevice::NullDevice()
|
|
{
|
|
}
|
|
|
|
NullDevice::~NullDevice()
|
|
{
|
|
}
|
|
|
|
bool NullDevice::hasDataAvailableForRead() const
|
|
{
|
|
return true;
|
|
}
|
|
|
|
Unix::ssize_t NullDevice::read(byte*, Unix::size_t)
|
|
{
|
|
kprintf("NullDevice: read from null\n");
|
|
return 0;
|
|
}
|
|
|
|
Unix::ssize_t NullDevice::write(const byte*, Unix::size_t bufferSize)
|
|
{
|
|
return min(GoodBufferSize, bufferSize);
|
|
}
|
|
|