Arachne  0.1
Public Member Functions | Public Attributes | List of all members
Arachne::ThreadContext Struct Reference

#include <Arachne.h>

Public Member Functions

 ThreadContext (ThreadContext &)=delete
 
 ThreadContext (uint8_t idInCore)
 

Public Attributes

void * stack
 
void * sp
 
volatile uint64_t wakeupTimeInCycles
 
uint32_t generation
 
SpinLock joinLock
 
ConditionVariable joinCV
 
uint8_t idInCore
 
 threadInvocation
 

Detailed Description

This class holds all the state for managing an Arachne thread.

Constructor & Destructor Documentation

Arachne::ThreadContext::ThreadContext ( uint8_t  idInCore)
explicit

Decrement the stack pointer by the amount of space needed to store the registers in swapcontext.

Member Data Documentation

uint32_t Arachne::ThreadContext::generation

Used as part of ThreadIds to differentiate Arachne threads that use this ThreadContext; incremented whenever an Arachne thread finishes execution in this ThreadContext.

uint8_t Arachne::ThreadContext::idInCore

Unique identifier for this thread among those on the same core. Used to index into various core-specific arrays. This is read-only after Arachne initialization.

ConditionVariable Arachne::ThreadContext::joinCV

Threads attempting to join the thread that currently occupies this context shall wait on this CV.

SpinLock Arachne::ThreadContext::joinLock

This lock is used for synchronizing threads that attempt to join this thread.

void* Arachne::ThreadContext::sp

This holds the value that rsp, the stack pointer register, will be set to when this thread is swapped in.

void* Arachne::ThreadContext::stack

Keep a reference to the original memory allocation for the stack used by this threadContext so that we can release the memory in shutDown.

Arachne::ThreadContext::threadInvocation

Storage for the ThreadInvocation object that contains the function and arguments for a new thread. We wrap the char buffer in a struct to enable aligning to a cache line boundary, which eliminates false sharing of cache lines.

volatile uint64_t Arachne::ThreadContext::wakeupTimeInCycles

This variable holds the minimum value of the cycle counter for which this thread can run. 0 is a signal that this thread should run at the next opportunity. ~0 is used as an infinitely large time: a sleeping thread will not awaken as long as wakeupTimeInCycles has this value.


The documentation for this struct was generated from the following files: