API Documentation


Thread Management

group thread

Defines

OPTIMSOC_THREAD_FLAG_IDLE_THREAD
OPTIMSOC_THREAD_FLAG_PIN
OPTIMSOC_THREAD_FLAG_CORE_MASK
OPTIMSOC_THREAD_FLAG_FORCEID
OPTIMSOC_THREAD_FLAG_KERNEL
OPTIMSOC_THREAD_FLAG_CREATE_SUSPENDED

Typedefs

typedef struct optimsoc_thread *optimsoc_thread_t

Thread identifier.

The internals are not exposed.

Functions

void optimsoc_thread_attr_init(struct optimsoc_thread_attr *attr)
int optimsoc_thread_create(optimsoc_thread_t *thread, void (*start)(void*), struct optimsoc_thread_attr *attr, )

Create a new thread.

The function allocates a thread data structure in the runtime system and stores the pointer to it at the given address. The function specified by start is called and the argument arg given to it. The function is automatically added to the ready queue.

optimsoc_thread_t optimsoc_thread_current()

Identify the thread currently running.

void optimsoc_thread_yield(optimsoc_thread_t thread)

Yield thread.

The specified thread is put at the end of the schedule. If the thread is the current thread (what makes most sense), the thread yields its remaining quantum and is scheduled to be executed later again (e.g., when waiting for I/O).

void optimsoc_thread_suspend(optimsoc_thread_t thread)

Suspend thread.

The specified thread is suspended until it gets reactivated.

void optimsoc_thread_exit()

Exit current thread’s execution.

void optimsoc_thread_resume(optimsoc_thread_t thread)

Resume a suspended thread.

void optimsoc_thread_add(optimsoc_thread_t thread)

Insert a thread in the system.

void optimsoc_thread_remove(optimsoc_thread_t thread)

Remove a thread from the system.

optimsoc_thread_t optimsoc_thread_dma_copy(uint32_t remote_tile, void *remote_addr)

Copy a remote thread with DMA

int optimsoc_thread_join(optimsoc_thread_t thread, optimsoc_thread_t waitforthread)

Wait for a thread until it exits.

If the thread is still running, the function blocks and waits for the finish of the thread. If it is already finished, the function returns immediately.

void optimsoc_thread_set_extra_data(optimsoc_thread_t thread, void *extra_data)

Extra data associated with a thread

The user or runtime system can set extra data with the thread.This can be a pointer to a process structure or similar.

Parameters
  • thread: Thread to assign the data pointer to

  • extra_data: Pointer to the data

void *optimsoc_thread_get_extra_data(optimsoc_thread_t thread)

Get extra data pointer

Retrieve the pointer to the extra data assigned to a thread.

Return

Associated data pointer

Parameters
  • thread: Thread to get data pointer from

void optimsoc_thread_set_pagedir(optimsoc_thread_t thread, optimsoc_page_dir_t dir)

Set page directory for thread

Assign a page directory to a thread.

Parameters
  • thread: Thread to assign page directory to

  • dir: Page directory to assign

optimsoc_page_dir_t optimsoc_thread_get_pagedir(optimsoc_thread_t thread)

Retrieve page directory of thread

Get the page directory associated with a thread

Return

Page directory

Parameters
  • thread: Thread to get page directory of

struct optimsoc_thread_attr