Skip to content
Snippets Groups Projects
Commit f2185d65 authored by g0dil's avatar g0dil
Browse files

Scheduler: Implement timer source switching API

Scheduler: Switch default timer source to lores / epoll()
parent b185fbb1
No related branches found
No related tags found
No related merge requests found
......@@ -54,6 +54,23 @@ prefix_ unsigned senf::scheduler::hangCount()
return scheduler::detail::FIFORunner::instance().hangCount();
}
prefix_ void senf::scheduler::hiresTimers()
{
detail::TimerDispatcher::instance().setTimerSource(
std::auto_ptr<TimerSource>(new POSIXTimerSource()));
}
prefix_ void senf::scheduler::loresTimers()
{
detail::TimerDispatcher::instance().setTimerSource(
std::auto_ptr<TimerSource>(new PollTimerSource()));
}
prefix_ bool senf::scheduler::haveScalableHiresTimers()
{
return false;
}
///////////////////////////////cci.e///////////////////////////////////////
#undef prefix_
......
......@@ -232,6 +232,32 @@ namespace scheduler {
/** \brief Number of watchdog events */
unsigned hangCount();
/** \brief Switch to using hi resolution timers
By default, timers are implemented directly using epoll. This however restricts the timer
resolution to that of the kernel HZ value.
High resolution timers are implemented either using POSIX timers or, when available, using
the Linux special \c timerfd() syscall.
POSIX timers are delivered using signals. A high timer load this increases the signal load
considerably. \c timerfd()'s are delivered on a file descriptor and thus don't have such a
scalability issue.
\warning The timer source must not be switched from a scheduler callback
*/
void hiresTimers();
/** \brief Switch back to using epoll for timing
\see hiresTimers()
*/
void loresTimers();
/** \brief return \c true, if \c timerfd() timing is available, \c false otherwise
\see hiresTimers()
*/
bool haveScalableHiresTimers();
/** \brief Restart scheduler
This call will restart all scheduler dispatchers (timers, signals, file descriptors). This
......
......@@ -34,7 +34,7 @@
///////////////////////////////cc.p////////////////////////////////////////
prefix_ senf::scheduler::detail::TimerDispatcher::TimerDispatcher()
: source_ (new POSIXTimerSource())
: source_ (new PollTimerSource())
{}
prefix_ senf::scheduler::detail::TimerDispatcher::~TimerDispatcher()
......
......@@ -98,6 +98,12 @@ prefix_ bool senf::scheduler::detail::TimerDispatcher::empty()
return timers_.empty();
}
prefix_ void senf::scheduler::detail::TimerDispatcher::
setTimerSource(std::auto_ptr<TimerSource> timerSource)
{
source_.reset(timerSource.release());
}
///////////////////////////////cci.e///////////////////////////////////////
#undef prefix_
......
......@@ -65,6 +65,8 @@ namespace detail {
bool empty() const;
void setTimerSource(std::auto_ptr<TimerSource> timerSource);
protected:
private:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment