UMS Context

A UMS context represents the state of a UMS thread.

Every UMS context is used for indexing its UMS thread owner by means of the ums_context.pid key.

Both a UMS scheduler and a UMS worker contains their own UMS context.

The UMS context implements all facilities for switching from UMS schedulers and UMS workers and viceversa.

Defines

CONTEXT_RUNNING

UMS context running state

CONTEXT_IDLE

UMS context idle state

__set_context_state(ctx, state_value)

Set context state.

Context: Any context.

Parameters
  • ctx[in] pointer to a UMS context

  • state_value[in] new state value

set_context_state(ctx, state_value)

Set context state and perform a write memory barrier.

Context: Any context.

Parameters
  • ctx[in] pointer to a UMS context

  • state_value[in] new state value

Structs

struct ums_context

UMS context structure

Public Members

unsigned int state

context state

struct task_struct *task

task_struct associated with the UMS context

pid_t pid

context key id

struct ums_context *parent

parent context

struct rhash_head node

context hashtable node

atomic_t switches

context switches counter

struct list_head list

head to context list forming a completion list

struct rcu_head rcu_head

rcu head

struct ums_data *data

pointer to UMS device private data where this context belongs to

Functions

void ums_context_init(struct ums_context *context)

Initialize a UMS context.

Set the context task as current and increment its reference counter.

The initialized context state is setted to CONTEXT_RUNNING.

Context: Any context.

Parameters
  • context[in] pointer to a UMS context

void ums_context_deinit(struct ums_context *context)

Deinitialize a UMS context.

Decrement context task reference counter.

Context: Any context.

Parameters
  • context[in] pointer to a UMS context

static inline pid_t current_context_pid(void)

Retrieve current UMS context pid.

Context: Any context.

Returns

The virtual pid of the current UMS context.

static inline void prepare_suspend_context(struct ums_context *context)

Initialize suspending UMS context.

Change context state to CONTEXT_IDLE

Context: Any context.

Parameters
  • context[in] pointer to a UMS context

static inline void wake_up_context(struct ums_context *context)

Wake up an idle UMS context.

Change context state to CONTEXT_RUNNING and wake up the context task.

Context: Any context.

Parameters
  • context[in] pointer to a UMS context

void prepare_switch_context(struct ums_context *from, struct ums_context *to)

Initialize a UMS context switch.

Assign the from context to the to->parent; suspend the from context and wake up the to context.

Context: Any context.

Parameters
  • from[in] pointer to the UMS context from which start the switch

  • to[in] pointer to the UMS context to which end the switch