Merge pull request #2397 from Subv/pulse
Kernel: Implemented Pulse event and timers.
This commit is contained in:
commit
84d72fd92f
|
@ -22,11 +22,6 @@ SharedPtr<Event> Event::Create(ResetType reset_type, std::string name) {
|
||||||
evt->reset_type = reset_type;
|
evt->reset_type = reset_type;
|
||||||
evt->name = std::move(name);
|
evt->name = std::move(name);
|
||||||
|
|
||||||
if (reset_type == ResetType::Pulse) {
|
|
||||||
LOG_ERROR(Kernel, "Unimplemented event reset type Pulse");
|
|
||||||
UNIMPLEMENTED();
|
|
||||||
}
|
|
||||||
|
|
||||||
return evt;
|
return evt;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -37,8 +32,7 @@ bool Event::ShouldWait(Thread* thread) const {
|
||||||
void Event::Acquire(Thread* thread) {
|
void Event::Acquire(Thread* thread) {
|
||||||
ASSERT_MSG(!ShouldWait(thread), "object unavailable!");
|
ASSERT_MSG(!ShouldWait(thread), "object unavailable!");
|
||||||
|
|
||||||
// Release the event if it's not sticky...
|
if (reset_type == ResetType::OneShot)
|
||||||
if (reset_type != ResetType::Sticky)
|
|
||||||
signaled = false;
|
signaled = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -51,4 +45,11 @@ void Event::Clear() {
|
||||||
signaled = false;
|
signaled = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Event::WakeupAllWaitingThreads() {
|
||||||
|
WaitObject::WakeupAllWaitingThreads();
|
||||||
|
|
||||||
|
if (reset_type == ResetType::Pulse)
|
||||||
|
signaled = false;
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
|
@ -38,6 +38,8 @@ public:
|
||||||
bool ShouldWait(Thread* thread) const override;
|
bool ShouldWait(Thread* thread) const override;
|
||||||
void Acquire(Thread* thread) override;
|
void Acquire(Thread* thread) override;
|
||||||
|
|
||||||
|
void WakeupAllWaitingThreads() override;
|
||||||
|
|
||||||
void Signal();
|
void Signal();
|
||||||
void Clear();
|
void Clear();
|
||||||
|
|
||||||
|
|
|
@ -157,7 +157,7 @@ public:
|
||||||
* Wake up all threads waiting on this object that can be awoken, in priority order,
|
* Wake up all threads waiting on this object that can be awoken, in priority order,
|
||||||
* and set the synchronization result and output of the thread.
|
* and set the synchronization result and output of the thread.
|
||||||
*/
|
*/
|
||||||
void WakeupAllWaitingThreads();
|
virtual void WakeupAllWaitingThreads();
|
||||||
|
|
||||||
/// Obtains the highest priority thread that is ready to run from this object's waiting list.
|
/// Obtains the highest priority thread that is ready to run from this object's waiting list.
|
||||||
SharedPtr<Thread> GetHighestPriorityReadyThread();
|
SharedPtr<Thread> GetHighestPriorityReadyThread();
|
||||||
|
|
|
@ -31,11 +31,6 @@ SharedPtr<Timer> Timer::Create(ResetType reset_type, std::string name) {
|
||||||
timer->interval_delay = 0;
|
timer->interval_delay = 0;
|
||||||
timer->callback_handle = timer_callback_handle_table.Create(timer).MoveFrom();
|
timer->callback_handle = timer_callback_handle_table.Create(timer).MoveFrom();
|
||||||
|
|
||||||
if (reset_type == ResetType::Pulse) {
|
|
||||||
LOG_ERROR(Kernel, "Unimplemented timer reset type Pulse");
|
|
||||||
UNIMPLEMENTED();
|
|
||||||
}
|
|
||||||
|
|
||||||
return timer;
|
return timer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -70,6 +65,13 @@ void Timer::Clear() {
|
||||||
signaled = false;
|
signaled = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Timer::WakeupAllWaitingThreads() {
|
||||||
|
WaitObject::WakeupAllWaitingThreads();
|
||||||
|
|
||||||
|
if (reset_type == ResetType::Pulse)
|
||||||
|
signaled = false;
|
||||||
|
}
|
||||||
|
|
||||||
/// The timer callback event, called when a timer is fired
|
/// The timer callback event, called when a timer is fired
|
||||||
static void TimerCallback(u64 timer_handle, int cycles_late) {
|
static void TimerCallback(u64 timer_handle, int cycles_late) {
|
||||||
SharedPtr<Timer> timer =
|
SharedPtr<Timer> timer =
|
||||||
|
|
|
@ -42,6 +42,8 @@ public:
|
||||||
bool ShouldWait(Thread* thread) const override;
|
bool ShouldWait(Thread* thread) const override;
|
||||||
void Acquire(Thread* thread) override;
|
void Acquire(Thread* thread) override;
|
||||||
|
|
||||||
|
void WakeupAllWaitingThreads() override;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Starts the timer, with the specified initial delay and interval.
|
* Starts the timer, with the specified initial delay and interval.
|
||||||
* @param initial Delay until the timer is first fired
|
* @param initial Delay until the timer is first fired
|
||||||
|
|
Loading…
Reference in New Issue