Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(EventManager): adds event counter #207

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions src/native/EventManager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include "Trace.h"
#include "VMem.h"


namespace {
struct InterruptHandler {
ebbrt::RcuHListHook hook;
Expand Down Expand Up @@ -135,6 +136,7 @@ void ebbrt::EventManager::Process() {
// instruction is executed (to allow for a halt for example). The nop gives us
// a one instruction window to process an interrupt (before the cli)
process:
Inc();
asm volatile("sti;"
"nop;"
"cli;");
Expand Down Expand Up @@ -175,7 +177,7 @@ void ebbrt::EventManager::FreeStack(Pfn stack) { free_stacks_.push(stack); }
static_assert(ebbrt::Cpu::kMaxCpus <= 256, "adjust event id calculation");

ebbrt::EventManager::EventManager(const RepMap& rm)
: reps_(rm), next_event_id_(Cpu::GetMine() << 24),
: reps_(rm), next_event_id_(Cpu::GetMine() << 24),
active_event_context_(next_event_id_++, AllocateStack()) {}

void ebbrt::EventManager::Spawn(MovableFunction<void()> func,
Expand Down Expand Up @@ -222,7 +224,7 @@ void ebbrt::EventManager::SpawnLocal(MovableFunction<void()> func,
tasks_.emplace_back(std::move(func));
} else {
sync_spawn_fn_ = std::move(func);

// put current context on the stack
sync_contexts_.emplace(std::move(active_event_context_));

Expand Down Expand Up @@ -394,6 +396,9 @@ void ebbrt::EventManager::ReceiveToken() {
StartTimer();
}




// Check Generation
void ebbrt::EventManager::Fire() {
if (generation_count_[pending_generation_ % 2] == 0) {
Expand Down
21 changes: 19 additions & 2 deletions src/native/EventManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@

#include <boost/container/flat_map.hpp>
#include <boost/utility.hpp>

#include "../MoveLambda.h"
#include "../Timer.h"

#include "Cpu.h"
#include "Isr.h"
#include "Main.h"
Expand Down Expand Up @@ -64,9 +64,11 @@ class EventManager : Timer::Hook {

explicit EventManager(const RepMap& rm);


static void Init();
static EventManager& HandleFault(EbbId id);

//void ReceiveMessage(ebbrt::Messenger::NetworkId nid, std::unique_ptr<ebbrt::IOBuf>&& buffer){};

void Spawn(ebbrt::MovableFunction<void()> func, bool force_async = false);
void SpawnLocal(ebbrt::MovableFunction<void()> func,
bool force_async = false);
Expand All @@ -79,6 +81,19 @@ class EventManager : Timer::Hook {
std::unordered_map<__gthread_key_t, void*>& GetTlsMap();
void DoRcu(MovableFunction<void()> func);
void Fire() override;
int Nodeval(){
auto sum = count;
for (size_t core = 0; core < Cpu::Count(); ++core){
auto it = reps_.find(core);
if(it != reps_.end()){
sum += it->second->Coreval();
} else{
ebbrt::kprintf("skipped core %d!", core);
}
}
return sum;
};
int Coreval(){ return count; };

private:
template <typename F> void InvokeFunction(F&& f);
Expand All @@ -98,6 +113,8 @@ class EventManager : Timer::Hook {
void ReceiveToken();
void CheckGeneration();
void StartTimer();
void Inc(){ count++; };
int count;

const RepMap& reps_;
std::stack<Pfn> free_stacks_;
Expand Down