gem5 v24.0.0.0
|
This class represents a fiber, which is a light weight sort of thread which is cooperatively scheduled and runs sequentially with other fibers, swapping in and out of a single actual thread of execution. More...
#include <fiber.hh>
Public Member Functions | |
virtual | ~Fiber () |
void | run () |
Start executing the fiber represented by this object. | |
bool | finished () const |
Returns whether the "main" function of this fiber has finished. | |
bool | started () const |
Returns whether the "main" function of this fiber has started. | |
Fiber (size_t stack_size=DefaultStackSize) | |
Fiber (Fiber *link, size_t stack_size=DefaultStackSize) | |
Static Public Member Functions | |
static Fiber * | currentFiber () |
Get a pointer to the current running Fiber. | |
static Fiber * | primaryFiber () |
Get a pointer to the primary Fiber. | |
Static Public Attributes | |
static const size_t | DefaultStackSize = 0x50000 |
Protected Member Functions | |
virtual void | main ()=0 |
This method is called when this fiber is first run. | |
void | setStarted () |
Private Member Functions | |
void | start () |
void | createContext () |
Static Private Member Functions | |
static void | entryTrampoline () |
Private Attributes | |
ucontext_t | ctx |
jmp_buf | jmp |
Fiber * | link |
void * | stack |
size_t | stackSize |
void * | guardPage |
size_t | guardPageSize |
bool | _started |
bool | _finished |
This class represents a fiber, which is a light weight sort of thread which is cooperatively scheduled and runs sequentially with other fibers, swapping in and out of a single actual thread of execution.
To define your own threads, create a subclass of Fiber and override its main() function to do what you want your fiber to do. You can start it by calling its run() method which will stop your execution and start the other fiber in your place.
If your main() function ends, that fiber will automatically switch to either the primary fiber, or to a particular fiber you specified at construction time, and your fiber is considered finished.
|
private |
|
staticprivate |
Definition at line 80 of file fiber.cc.
Referenced by createContext().
|
protectedpure virtual |
This method is called when this fiber is first run.
Override it to give your fiber something to do. When main returns, the fiber will mark itself as finished and switch to its link fiber.
Implemented in gem5::Coroutine< Arg, Ret >, LinkedFiber, sc_gem5::ScMainFiber, sc_gem5::Thread::Context, and SwitchingFiber.
|
inlineprotected |
|
private |
|
private |
Definition at line 165 of file fiber.hh.
Referenced by finished(), run(), and start().
|
private |
Definition at line 164 of file fiber.hh.
Referenced by run(), setStarted(), and started().
|
private |
Definition at line 148 of file fiber.hh.
Referenced by createContext(), and start().
|
private |
|
private |
|
private |
|
private |
Definition at line 156 of file fiber.hh.
Referenced by createContext(), Fiber(), and ~Fiber().
|
private |
Definition at line 157 of file fiber.hh.
Referenced by createContext(), and ~Fiber().