Parlib
Easing Cross-Platform Development of Next Generation Parallel Systems
Amplab

Table Of Contents

Previous topic

Vcores

Next topic

MCS Locks

This Page

Uthreads

To access the uthread API, include the following header file:

#include <parlib/uthread.h>

Constants

#define UTH_EXT_BLK_MUTEX
UTH_EXT_BLK_MUTEX

One, of possibly many in the future, reasons that a uthread has blocked externally. This is required for proper implementation of the uthread_has_blocked() API call.

Types

struct uthread;
typedef struct uthread uthread_t;

struct schedule_ops;
typedef struct schedule_ops schedule_ops_t;
struct uthread
uthread_t

An opaque type used to reference and manage a user-level thread

struct schedule_ops
schedule_ops_t

A struct containing the list of callbacks a user-level scheduler built on top of this uthread library needs to implement.

struct schedule_ops {
    void (*sched_entry)(void);
    void (*thread_runnable)(struct uthread *);
    void (*thread_paused)(struct uthread *);
    void (*thread_blockon_sysc)(struct uthread *, void *);
    void (*thread_has_blocked)(struct uthread *, int);
    void (*preempt_pending)(void);
    void (*spawn_thread)(uintptr_t pc_start, void *data);
};
void schedule_ops_t.sched_entry()
void schedule_ops_t.thread_runnable(struct uthread *)
void schedule_ops_t.thread_paused(struct uthread *)
void schedule_ops_t.thread_blockon_sysc(struct uthread *, void *)
void schedule_ops_t.thread_has_blocked(struct uthread *, int)
void schedule_ops_t.preempt_pending()
void schedule_ops_t.spawn_thread(uintptr_t pc_start, void *data)

External Symbols

extern struct schedule_ops *sched_ops;
extern struct schedule_ops *sched_ops

A reference to an externally defined variable which contains pointers to implementations of all the schedule_ops callbacks.

Global Variables

__thread uthread_t *current_uthread;
__thread uthread_t *current_uthread

API Calls

int uthread_lib_init();
void uthread_cleanup(struct uthread *uthread);
void uthread_runnable(struct uthread *uthread);
void uthread_yield(bool save_state, void (*yield_func)(struct uthread*, void*), void *yield_arg);
void save_current_uthread(struct uthread *uthread);
void highjack_current_uthread(struct uthread *uthread);
void run_current_uthread(void);
void run_uthread(struct uthread *uthread);
void swap_uthreads(struct uthread *__old, struct uthread *__new);
init_uthread_tf(uthread_t *uth, void (*entry)(void), void *stack_bottom, uint32_t size);

#define uthread_begin_access_tls_vars(uthread)
#define uthread_end_access_tls_vars()
#define uthread_set_tls_var(uthread, name, val)
#define uthread_get_tls_var(uthread, name)
int uthread_lib_init()
void uthread_cleanup(struct uthread *uthread)
void uthread_runnable(struct uthread *uthread)
void uthread_yield(bool save_state, void (*yield_func)(struct uthread*, void*), void *yield_arg)
void save_current_uthread(struct uthread *uthread)
void highjack_current_uthread(struct uthread *uthread)
void run_current_uthread(void)

This function does not return.

void run_uthread(struct uthread *uthread)

This function does not return.

void swap_uthreads(struct uthread *__old, struct uthread *__new)
init_uthread_tf(uthread_t *uth, void (*entry)(void), void *stack_bottom, uint32_t size)
#define uthread_begin_access_tls_vars(uthread)
#define uthread_end_access_tls_vars()
#define uthread_set_tls_var(uthread, name, val)
#define uthread_get_tls_var(uthread, name)