The ROme OpTimistic Simulator  2.0.0
A General-Purpose Multithreaded Parallel/Distributed Simulation Platform
ult.h File Reference

User-Level Threads Headers. More...

#include <core/core.h>
#include <arch/jmp.h>
+ Include dependency graph for ult.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define context_save(context)   set_jmp(context)
 Save machine context for userspace context switch. More...
 
#define context_restore(context)   long_jmp(context, 1)
 Restore machine context for userspace context switch. This is used only in inizialitaion.
 
#define context_switch(context_old, context_new)
 Swicth machine context for userspace context switch. This is used to schedule a LP or return control to simulation kernel. More...
 
#define context_switch_create(context_old, context_new)
 Swicth machine context for userspace context switch. This is used to schedule a LP or return control to simulation kernel. More...
 

Typedefs

typedef exec_context_t LP_context_t
 Definition of an execution context for an LP. This is just syntactic sugar.
 
typedef exec_context_t kernel_context_t
 Definition of an execution context for a worker thread. This is just syntactic sugar.
 

Functions

void * get_ult_stack (size_t size)
 

Variables

__thread kernel_context_t kernel_context
 This is the execution context of the simulation kernel.
 

Detailed Description

User-Level Threads Headers.

The User-Level Thread module allows the creation/scheduling of multiple co-routines which can yield the CPU to a different one, or that can be preƫmpted by some asynchronous event.

Due to the possibility of external preƫmption, ULTs store the whole CPU context in an ad-hoc buffer. This is a significant difference with respect standard facilities such as setjmp/longjmp which only store callee-save registers.

ULTs are used to implement both runtime-level routines (each worker thread has its own execution context) and model-level routines (each LP has its own execution context).

This file is part of ROOT-Sim (ROme OpTimistic Simulator).

ROOT-Sim is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; only version 3 of the License applies.

ROOT-Sim is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with ROOT-Sim; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA

Author
Alessandro Pellegrini

Definition in file ult.h.

Macro Definition Documentation

#define context_save (   context)    set_jmp(context)

Save machine context for userspace context switch.

This macro performs a context save in the specified context (a pointer).

This is used only in initialization to setup the execution contexts. After that, the platform only relies on context_switch()

Parameters
contextA pointer to the exec_context_t to save the current CPU context into.

Definition at line 69 of file ult.h.

#define context_switch (   context_old,
  context_new 
)
Value:
if(set_jmp(context_old) == 0) \
long_jmp(context_new, (context_new)->rax)
#define set_jmp(env)
Definition: jmp.h:91
#define long_jmp(env, val)
Definition: jmp.h:109

Swicth machine context for userspace context switch. This is used to schedule a LP or return control to simulation kernel.

Definition at line 75 of file ult.h.

#define context_switch_create (   context_old,
  context_new 
)
Value:
if(set_jmp(context_old) == 0) \
long_jmp(context_new, 1)
#define set_jmp(env)
Definition: jmp.h:91
#define long_jmp(env, val)
Definition: jmp.h:109

Swicth machine context for userspace context switch. This is used to schedule a LP or return control to simulation kernel.

Definition at line 80 of file ult.h.

Function Documentation

void* get_ult_stack ( size_t  size)

When this function is called, a zeroed page-aligned stack for the ULT is created and returned. The size of the stack can be specified by using the parameter. It's suggested to give a stack size which is a multiple of the page size. Nevertheless, no check is done by this function.

Author
Alessandro Pellegrini
Parameters
sizeThe size of the requested stack
Returns
A pointer to the allocated and zeroed page-aligned stack

Definition at line 65 of file ult.c.

+ Here is the call graph for this function: