mirror of
https://github.com/fergalmoran/ladybird.git
synced 2026-01-06 00:25:12 +00:00
Kernel: Move block condition evaluation out of the Scheduler
This makes the Scheduler a lot leaner by not having to evaluate block conditions every time it is invoked. Instead evaluate them as the states change, and unblock threads at that point. This also implements some more waitid/waitpid/wait features and behavior. For example, WUNTRACED and WNOWAIT are now supported. And wait will now not return EINTR when SIGCHLD is delivered at the same time.
This commit is contained in:
@@ -95,6 +95,11 @@ FIFO::FIFO(uid_t uid)
|
||||
LOCKER(all_fifos().lock());
|
||||
all_fifos().resource().set(this);
|
||||
m_fifo_id = ++s_next_fifo_id;
|
||||
|
||||
// Use the same block condition for read and write
|
||||
m_buffer.set_unblock_callback([this]() {
|
||||
evaluate_block_conditions();
|
||||
});
|
||||
}
|
||||
|
||||
FIFO::~FIFO()
|
||||
@@ -116,6 +121,8 @@ void FIFO::attach(Direction direction)
|
||||
klog() << "open writer (" << m_writers << ")";
|
||||
#endif
|
||||
}
|
||||
|
||||
evaluate_block_conditions();
|
||||
}
|
||||
|
||||
void FIFO::detach(Direction direction)
|
||||
@@ -133,6 +140,8 @@ void FIFO::detach(Direction direction)
|
||||
ASSERT(m_writers);
|
||||
--m_writers;
|
||||
}
|
||||
|
||||
evaluate_block_conditions();
|
||||
}
|
||||
|
||||
bool FIFO::can_read(const FileDescription&, size_t) const
|
||||
|
||||
Reference in New Issue
Block a user