UMS Worker

Overview

The life cycle of a UMS worker is bounded to the process that opens the UMS device and it is represented by the ums_worker structure. Once created, it is stored inside the pool of workers pointed by ums_data.workers. The kernel rhashtable structure has been choosen for representing the workers pool since the number of UMS workers that are going to be created isn’t known in advance. In this way the size of the hashtable will be automatically adjusted providing better performances. Every UMS worker is indexed inside the pool by its ums_worker.context.

When a UMS worker is created it is registered to the dedicated UMS procfs at /proc/ums/<pid>/workers/<worker-pid>, where <pid> is the PID of the process that opens the UMS device and <worker-pid> is the PID of the UMS worker. Once a UMS worker terminates it is unregistered from the UMS procfs.

Structs

struct ums_worker

UMS worker struct

Public Members

struct ums_context context

worker context

struct ums_complist *complist

worker completion list

struct ums_worker_proc_dirs dirs

worker procfs dirs

Functions

int enter_ums_worker_mode(struct ums_data *data, struct enter_ums_mode_args *args)

Enter UMS worker mode.

Creates a UMS worker, add its UMS context to the UMS completion list and suspend the UMS worker.

Context: Process context. May sleep. Takes and releases the RCU lock.

Parameters
  • data[in] pointer to the UMS data

  • args[in] userspace pointer for args

Returns

  • 0 - OK

  • -ENOMEM - No memory available

  • -EINVAL - Invalid UMS completion list arg

int ums_worker_yield(struct ums_data *data, void *args)

Yield UMS worker.

Add the UMS worker context to the UMS completion list, enqueue a UMS scheduling event of type THREAD_YIELD to the parent UMS scheduler and switch the UMS context with the parent one.

Context: Process context. May sleep. Takes and releases the RCU lock.

Parameters
  • data[in] pointer to the UMS data

  • args[in] userspace pointer for args

Returns

  • 0 - OK

  • -ESRCH - Bad UMS calling thread

  • -ENOMEM - No memory available

int ums_worker_end(struct ums_data *data)

Terminate a UMS worker.

Enqueue a UMS scheduling event of type THREAD_TERMINATED to the parent UMS scheduler, destroy the UMS worker and wake up the parent UMS scheduler.

Context: Process context. May sleep. Takes and releases the RCU lock.

Parameters
  • data[in] pointer to the UMS data

Returns

  • 0 - OK

  • -ESRCH - Bad UMS calling thread

  • -ENOMEM - No memory available

void ums_worker_destroy(struct ums_worker *worker)

Destroy the UMS worker.

Context: Process context.

Parameters
  • worker[in] pointer to the UMS worker