mirror of
https://github.com/matrix-construct/construct
synced 2025-03-14 05:20:17 +01:00
ircd::ctx: Add state for counting context switches.
This commit is contained in:
parent
08be1cb010
commit
e15ac0d1d3
3 changed files with 10 additions and 0 deletions
|
@ -53,6 +53,7 @@ namespace ircd::ctx
|
|||
const size_t &stack_max(const ctx &); // Returns stack size allocated for ctx
|
||||
const size_t &stack_at(const ctx &); // Stack at last sleep (also see this_ctx.h)
|
||||
const int64_t ¬es(const ctx &); // Peeks at internal semaphore count
|
||||
const uint64_t &yields(const ctx &); // Context switching counter
|
||||
const ulong &cycles(const ctx &); // Accumulated tsc (not counting cur slice)
|
||||
bool interruption(const ctx &); // Context was marked for interruption
|
||||
bool termination(const ctx &); // Context was marked for termination
|
||||
|
|
|
@ -381,6 +381,13 @@ ircd::ctx::cycles(const ctx &ctx)
|
|||
return ctx.cycles;
|
||||
}
|
||||
|
||||
/// Returns the yield count for `ctx`
|
||||
const uint64_t &
|
||||
ircd::ctx::yields(const ctx &ctx)
|
||||
{
|
||||
return ctx.yields;
|
||||
}
|
||||
|
||||
/// Returns the notification count for `ctx`
|
||||
const int64_t &
|
||||
ircd::ctx::notes(const ctx &ctx)
|
||||
|
@ -636,6 +643,7 @@ ircd::ctx::continuation::continuation(ctx *const &self)
|
|||
assert(!std::current_exception());
|
||||
//assert(!std::uncaught_exceptions());
|
||||
|
||||
self->yields++;
|
||||
self->cont = this;
|
||||
ircd::ctx::current = nullptr;
|
||||
}
|
||||
|
|
|
@ -28,6 +28,7 @@ struct ircd::ctx::ctx
|
|||
size_t stack_at {0}; // Updated for profiling at sleep
|
||||
int64_t notes {0}; // norm: 0 = asleep; 1 = awake; inc by others; dec by self
|
||||
ulong cycles {0}; // monotonic counter (rdtsc)
|
||||
uint64_t yields {0}; // monotonic counter
|
||||
continuation *cont {nullptr}; // valid when asleep; invalid when awake
|
||||
ctx *adjoindre {nullptr}; // context waiting for this to join()
|
||||
list::node node; // node for ctx::list
|
||||
|
|
Loading…
Add table
Reference in a new issue