cuflow/gworkq.h Global Work Queue
[[deprecated] Old SMP Work Scheduling]

Defines

#define cuflow_priority_postmax   16
#define cuflow_priority_realtime   13
#define cuflow_priority_interactive   10
#define cuflow_priority_normal   7
#define cuflow_priority_background   3

Typedefs

typedef int cuflow_priority_t

Functions

cuflow_priority_t cuflow_gworkq_current_priority (void)
cuflow_priority_t cuflow_gworkq_set_static_priority (cuflow_priority_t pri)
cu_bool_t cuflow_gworkq_yield_at (int priority)
cu_bool_t cuflow_gworkq_yield_at_glck (int priority)
cu_bool_t cuflow_gworkq_yieldall_prior (void)
cu_bool_t cuflow_gworkq_yieldall_prioreq (void)
void cuflow_gworkq_yield_gcond_glck (void)
cu_bool_t cuflow_gworkq_yield_idle (void)
void cuflow_gworkq_sched_at (cuflow_workq_fn_t fn, cuflow_priority_t priority)
void cuflow_gworkq_sched (cuflow_workq_fn_t fn)
void cuflow_gworkq_dump (FILE *out)
void cuflow_gworkq_lock ()
void cuflow_gworkq_unlock ()
void cuflow_gworkq_broadcast ()

Variables

pthread_mutex_t cuflowP_gworkq_mutex
pthread_cond_t cuflowP_gworkq_cond

Detailed Description

Deprecated:
cuflow/sched.h provides a simpler and more efficient alternative.

The global work queue is a way for threads to co-operate to performed scheduled function calls in order of priority and in FIFO order within a given priority.

On SMP systems, this can be used to parallelise work by letting threads performing low-priority tasks help out the high-priority threads when work is available. The global work queue can also be useful on non-SMP systems to run tasks while waiting for resources to become available.


Define Documentation

#define cuflow_priority_background   3

The priority of tasks which are to be run only when there is nothing else to do.

#define cuflow_priority_interactive   10

The priority of interacive tasks like GUI or curses dialogs.

#define cuflow_priority_normal   7

The priority of common tasks with no specific need.

#define cuflow_priority_postmax   16

One above the maximum priority.

#define cuflow_priority_realtime   13

The priority of realtime tasks like audio and video.


Function Documentation

cuflow_priority_t cuflow_gworkq_current_priority ( void   ) 

The current priority of the running thread.

void cuflow_gworkq_dump ( FILE *  out  ) 

Debug dump of global work queues.

void cuflow_gworkq_sched ( cuflow_workq_fn_t  fn  ) 

Schedule fn on the current thread's work queue. If a flexible-priority queue is active for the thread, it is used, otherwise a the static-priority queue at the same priority as the thread is used.

void cuflow_gworkq_sched_at ( cuflow_workq_fn_t  fn,
cuflow_priority_t  priority 
)

Schedule fn to be called at fixed priority.

cuflow_priority_t cuflow_gworkq_set_static_priority ( cuflow_priority_t  pri  ) 

Set the current static priority of the running thread and return its previous priority.

Precondition:
The current thread must be running on a static-priority queue.
cu_bool_t cuflow_gworkq_yield_at ( int  priority  ) 

Yield the processor to tasks at or above priority in the global work queue and return true iff some work was done. The selected task is the first task of the highest priority non-empty queue.

cu_bool_t cuflow_gworkq_yield_idle ( void   ) 

Same as cuflow_gworkq_yieldall_prior, except that if no work was done, try also to run a single task at the current priority. Returns true iff some work was done. This is useful while waiting for resources.

cu_bool_t cuflow_gworkq_yieldall_prior ( void   ) 

Yield the processor to work above the current priority until there is no more such work. Returns true iff some work was done. This can be scattered at strategic points in low-priority code to give more CPUs to high priority tasks.

cu_bool_t cuflow_gworkq_yieldall_prioreq ( void   ) 

Yield the processor to work at or above the current priority until there is no more such work. Returns true iff some work was done.

Generated 2009-11-23 for culibs-0.25 using Doxygen. Maintained by Petter Urkedal.