Functions

/home/mesh/mesh/include/mesh_syscalls.h File Reference

MESH system calls header. More...

Go to the source code of this file.

Functions

void mesh_yield ()
 Immediately returns control to the scheduler committing any outstanding lightweight consumes in the process. Useful for forcing the scheduler to run after creating new threads, etc.
void mesh_thread_create_entry (mesh_thread *cr, gchar *key, void *value)
 Associates a key-value pair with a thread. Useful for storing thread-local data without having to change its type definition.
gboolean mesh_thread_has_entry (mesh_thread *cr, gchar *key, void **value)
 Retrives the current value of the specified thread entry if it exists.
void * mesh_thread_get_entry (mesh_thread *cr, gchar *key)
 Retrives the current value of the specified thread entry.
void mesh_thread_set_entry (mesh_thread *cr, gchar *key, void *value)
 Changes the current value of the specified thread entry.
void mesh_resource_create_entry (mesh_resource *cr, gchar *key, void *value)
 Associates a key-value pair with a resource. Useful for storing resource-local data without having to change its type definition.
void * mesh_resource_get_entry (mesh_resource *cr, gchar *key)
 Retrives the current value of the specified resource entry.
void mesh_resource_set_entry (mesh_resource *cr, gchar *key, void *value)
 Changes the current value of the specified resource entry.
void mesh_scheduler_create_entry (mesh_scheduler *cs, gchar *key, void *value)
 Associates a key-value pair with a scheduler. Useful for storing scheduler-local data without having to change its type definition.
void * mesh_scheduler_get_entry (mesh_scheduler *cs, gchar *key)
 Retrives the current value of the specified scheduler entry.
void mesh_scheduler_set_entry (mesh_scheduler *cs, gchar *key, void *value)
 Changes the current value of the specified scheduler entry.
void mesh_thread_inc_counter (double)
 Increment the thread specific counter.
double mesh_thread_get_and_clear_counter ()
 Return and clear the thread specific counter. This can be used to implement coarse-grained consumes.
gint mesh_thread_sem_wait (mesh_thread_sem *sem)
 Block until the semaphore value is greater than zero, then decrement it.
gint mesh_thread_sem_trywait (mesh_thread_sem *sem)
 Attempt to decrement the semaphore. Return -1 if the semaphore value is not greater than zero. Return 0 if the semaphore value is greater than zero and the decrement succeeds. This call does not block.
gint mesh_thread_sem_post (mesh_thread_sem *sem)
 Increment the semaphore value. This should always succeed.
gint mesh_thread_sem_post_delayed (mesh_thread_sem *sem)
 Increment the semaphore value after the next consume call. This uses an implicit increment-memcpy operation in the kernel perform_delayed_actions() function that is activated when the src and dest of memcpy is equal. Since memcpy() does not support equal src and dest addresses, this was special case was used to minimize changes in the code.
gint mesh_thread_mutex_init (mesh_thread_mutex *mutex, void *attr)
 Initializes the mutex pointed to by mutex.
gint mesh_thread_mutex_lock (mesh_thread_mutex *mutex)
 Locks the given mutex. If the mutex is currently locked mesh_thread_mutex_lock.
gint mesh_thread_mutex_unlock (mesh_thread_mutex *mutex)
 Unlocks the given mutex. Resumes any other logical threads which are blocked on this mutex.
gint mesh_thread_mutex_unlock_delayed (mesh_thread_mutex *mutex)
 Unlocks the given mutex at the end of this consume region. Resumes any other logical threads which are blocked on this mutex.
gint mesh_thread_mutex_destroy (mesh_thread_mutex *mutex)
 Destroys the mutex specified by mutex. The mutex must be unlocked on entrance. This frees all resources associated with the mutex.
gint mesh_thread_mutex_trylock (mesh_thread_mutex *mutex)
 Behaves identically to mesh_thread_mutex_lock except that it does not block if the mutex is already locked. Instead it.

Detailed Description

MESH system calls header.


Function Documentation

void mesh_resource_create_entry ( mesh_resource *  cr,
gchar *  key,
void *  value 
)

Associates a key-value pair with a resource. Useful for storing resource-local data without having to change its type definition.

Parameters:
cr Resource to create entry for
key Entry key
value Entry starting value precond The key must not already be in use
See also:
mesh_resource_get_entry(), mesh_resource_set_entry()
void* mesh_resource_get_entry ( mesh_resource *  cr,
gchar *  key 
)

Retrives the current value of the specified resource entry.

Parameters:
cr Resource to get entry for
key Entry's key precond Entry must have been previously created by calling mesh_resource_create_entry() .
Returns:
The entry's value
See also:
mesh_resource_create_entry(), mesh_resource_set_entry()
void mesh_resource_set_entry ( mesh_resource *  cr,
gchar *  key,
void *  value 
)

Changes the current value of the specified resource entry.

Parameters:
cr Resource to set entry for
key Entry's key
value Entry's new value precond Entry must have been previously created by calling mesh_resource_create_entry() .
See also:
mesh_resource_create_entry(), mesh_resource_get_entry()
void mesh_scheduler_create_entry ( mesh_scheduler *  cs,
gchar *  key,
void *  value 
)

Associates a key-value pair with a scheduler. Useful for storing scheduler-local data without having to change its type definition.

Parameters:
cr Scheduler to create entry for
key Entry's key
value Entry's starting value precond The key must not already be in use
See also:
mesh_scheduler_get_entry(), mesh_scheduler_set_entry()
void* mesh_scheduler_get_entry ( mesh_scheduler *  cs,
gchar *  key 
)

Retrives the current value of the specified scheduler entry.

Parameters:
cr Scheduler to get entry for
key Entry's key precond Entry must have been previously created by calling mesh_scheduler_create_entry() .
Returns:
The entry's value
See also:
mesh_scheduler_create_entry(), mesh_scheduler_set_entry()
void mesh_scheduler_set_entry ( mesh_scheduler *  cs,
gchar *  key,
void *  value 
)

Changes the current value of the specified scheduler entry.

Parameters:
cr Scheduler to set entry for
key Entry's key
value Entry's new value precond Entry must have been previously created by calling mesh_scheduler_create_entry() .
See also:
mesh_scheduler_create_entry(), mesh_scheduler_get_entry()
void mesh_thread_create_entry ( mesh_thread *  cr,
gchar *  key,
void *  value 
)

Associates a key-value pair with a thread. Useful for storing thread-local data without having to change its type definition.

Parameters:
cr Thread to create entry for
key Entry's key
value Entry's starting value precond The key must not already be in use
See also:
mesh_thread_get_entry(), mesh_thread_has_entry(), mesh_thread_set_entry()
double mesh_thread_get_and_clear_counter (  ) 

Return and clear the thread specific counter. This can be used to implement coarse-grained consumes.

Returns:
Current contents of thread specific counter
See also:
mesh_thread_inc_counter()
void* mesh_thread_get_entry ( mesh_thread *  cr,
gchar *  key 
)

Retrives the current value of the specified thread entry.

Parameters:
cr Thread to get entry for
key Entry's key precond Entry must have been previously created by calling mesh_thread_create_entry() .
Returns:
The entry's value
See also:
mesh_thread_create_entry(), mesh_thread_has_entry(), mesh_thread_set_entry()
gboolean mesh_thread_has_entry ( mesh_thread *  cr,
gchar *  key,
void **  value 
)

Retrives the current value of the specified thread entry if it exists.

Parameters:
cr Thread to check for entry
key Entry's key
value Pointer to hold entry (if it exists)
Returns:
TRUE if the entry exists
See also:
mesh_thread_create_entry(), mesh_thread_get_entry(), mesh_thread_set_entry()
void mesh_thread_inc_counter ( double  val  ) 

Increment the thread specific counter.

See also:
mesh_thread_get_and_clear_counter()
gint mesh_thread_mutex_destroy ( mesh_thread_mutex *  mutex  ) 

Destroys the mutex specified by mutex. The mutex must be unlocked on entrance. This frees all resources associated with the mutex.

Parameters:
mutex Mutex to destroy
Returns:
0 for success, non-zero for failure
See also:
pthread_mutex_destroy()
gint mesh_thread_mutex_init ( mesh_thread_mutex *  mutex,
void *  attr 
)

Initializes the mutex pointed to by mutex.

Parameters:
mutex Mutex to create
attr Attributes, not used
Returns:
0 for success, non-zero for failure
See also:
pthread_mutex_init()
gint mesh_thread_mutex_lock ( mesh_thread_mutex *  mutex  ) 

Locks the given mutex. If the mutex is currently locked mesh_thread_mutex_lock.

Parameters:
mutex Mutex to lock
Returns:
immediately. Otherwise it blocks until the mutex is released.
0 for success, non-zero for failure
See also:
pthread_mutex_lock()
gint mesh_thread_mutex_trylock ( mesh_thread_mutex *  mutex  ) 

Behaves identically to mesh_thread_mutex_lock except that it does not block if the mutex is already locked. Instead it.

Parameters:
mutex Mutex to attempt to lock
Returns:
immediately with an error code.
0 for success, non-zero for failure
See also:
pthread_mutex_trylock(), mesh_thread_mutex_lock()
gint mesh_thread_mutex_unlock ( mesh_thread_mutex *  mutex  ) 

Unlocks the given mutex. Resumes any other logical threads which are blocked on this mutex.

Parameters:
mutex Mutex to unlock
Returns:
0 for success, non-zero for failure
See also:
pthread_mutex_unlock(), mesh_thread_mutex_lock()
gint mesh_thread_mutex_unlock_delayed ( mesh_thread_mutex *  mutex  ) 

Unlocks the given mutex at the end of this consume region. Resumes any other logical threads which are blocked on this mutex.

Parameters:
mutex Mutex to unlock
Returns:
0 for success, non-zero for failure
See also:
pthread_mutex_unlock(), mesh_thread_mutex_lock()
gint mesh_thread_sem_post ( mesh_thread_sem *  sem  ) 

Increment the semaphore value. This should always succeed.

Parameters:
sem Semaphore to increment
Returns:
0 for success, non-zero for failure
See also:
sem_post()
gint mesh_thread_sem_post_delayed ( mesh_thread_sem *  sem  ) 

Increment the semaphore value after the next consume call. This uses an implicit increment-memcpy operation in the kernel perform_delayed_actions() function that is activated when the src and dest of memcpy is equal. Since memcpy() does not support equal src and dest addresses, this was special case was used to minimize changes in the code.

Parameters:
sem Semaphore to increment
Returns:
0 for success, non-zero for failure
See also:
sem_post()
gint mesh_thread_sem_trywait ( mesh_thread_sem *  sem  ) 

Attempt to decrement the semaphore. Return -1 if the semaphore value is not greater than zero. Return 0 if the semaphore value is greater than zero and the decrement succeeds. This call does not block.

Parameters:
sem Semaphore to decrement
Returns:
0 for success, non-zero for failure
See also:
sem_trywait()
gint mesh_thread_sem_wait ( mesh_thread_sem *  sem  ) 

Block until the semaphore value is greater than zero, then decrement it.

Parameters:
sem Semaphore to decrement
Returns:
0 for success, non-zero for failure
See also:
sem_wait()
void mesh_thread_set_entry ( mesh_thread *  cr,
gchar *  key,
void *  value 
)

Changes the current value of the specified thread entry.

Parameters:
cr Thread to set entry for
key Entry's key
value Entry's new value precond Entry must have been previously created by calling mesh_thread_create_entry() .
See also:
mesh_thread_create_entry(), mesh_thread_get_entry()
void mesh_yield (  ) 

Immediately returns control to the scheduler committing any outstanding lightweight consumes in the process. Useful for forcing the scheduler to run after creating new threads, etc.

See also:
mesh_lightweight_consume()
 All Files Functions