diff options
Diffstat (limited to 'include/odp/api/spec/thread.h')
-rw-r--r-- | include/odp/api/spec/thread.h | 119 |
1 files changed, 66 insertions, 53 deletions
diff --git a/include/odp/api/spec/thread.h b/include/odp/api/spec/thread.h index 689ba59b5..34d3c2b82 100644 --- a/include/odp/api/spec/thread.h +++ b/include/odp/api/spec/thread.h @@ -1,70 +1,39 @@ -/* Copyright (c) 2013, Linaro Limited - * All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright (c) 2013-2018 Linaro Limited + * Copyright (c) 2022-2023 Nokia */ - /** * @file * * ODP thread API */ -#ifndef ODP_API_THREAD_H_ -#define ODP_API_THREAD_H_ +#ifndef ODP_API_SPEC_THREAD_H_ +#define ODP_API_SPEC_THREAD_H_ #include <odp/visibility_begin.h> #ifdef __cplusplus extern "C" { #endif -/** @defgroup odp_thread ODP THREAD - * @{ - */ +#include <odp/api/thread_types.h> -/** - * @def ODP_THREAD_COUNT_MAX - * Maximum number of threads supported in build time. Use - * odp_thread_count_max() for maximum number of threads supported in run time, - * which depend on system configuration and may be lower than this number. - */ - -/** - * Thread type +/** @addtogroup odp_thread + * Thread types, masks and IDs. + * @{ */ -typedef enum odp_thread_type_e { - /** - * Worker thread - * - * Worker threads do most part of ODP application packet processing. - * These threads provide high packet and data rates, with low and - * predictable latency. Typically, worker threads are pinned to isolated - * CPUs and packets are processed in a run-to-completion loop with very - * low interference from the operating system. - */ - ODP_THREAD_WORKER = 0, - - /** - * Control thread - * - * Control threads do not participate the main packet flow through the - * system, but e.g. control or monitor the worker threads, or handle - * exceptions. These threads may perform general purpose processing, - * use system calls, share the CPU with other threads and be interrupt - * driven. - */ - ODP_THREAD_CONTROL -} odp_thread_type_t; - /** * Get thread identifier * - * Returns the thread identifier of the current thread. Thread ids range from 0 - * to odp_thread_count_max() - 1. The ODP thread id is assigned by - * odp_init_local() and freed by odp_term_local(). Thread id is unique within - * the ODP instance. + * Returns the ODP thread identifier of current thread. Thread IDs range from 0 + * to odp_thread_count_max() - 1 and are unique within an ODP instance. + * + * Thread IDs are assigned by odp_init_local() and freed by odp_term_local(). + * IDs are assigned sequentially starting from 0 in the same order threads call + * odp_init_local(). Thread IDs freed by odp_term_local() may be reused by + * following odp_init_local() calls. * * @return Thread identifier of the current thread */ @@ -74,25 +43,70 @@ int odp_thread_id(void); * Thread count * * Returns the current ODP thread count. This is the number of active threads - * running the ODP instance. Each odp_init_local() call increments and each - * odp_term_local() call decrements the count. The count is always between 1 and - * odp_thread_count_max(). + * of any type running in the ODP instance. Each odp_init_local() call + * increments and each odp_term_local() call decrements the count. The count is + * always between 1 and odp_thread_count_max(). * * @return Current thread count */ int odp_thread_count(void); /** + * Control thread count + * + * Otherwise like odp_thread_count(), but returns the number of active threads + * of type #ODP_THREAD_CONTROL. The count is always between 0 and + * odp_thread_control_count_max(). + * + * @return Current control thread count + */ +int odp_thread_control_count(void); + +/** + * Worker thread count + * + * Otherwise like odp_thread_count(), but returns the number of active threads + * of type #ODP_THREAD_WORKER. The count is always between 0 and + * odp_thread_worker_count_max(). + * + * @return Current worker thread count + */ +int odp_thread_worker_count(void); + +/** * Maximum thread count * - * Returns the maximum thread count, which is a constant value and set in - * ODP initialization phase. This may be lower than ODP_THREAD_COUNT_MAX. + * Returns the maximum number of threads of any type. This is a constant value + * and set in ODP initialization phase. The value may be lower than + * #ODP_THREAD_COUNT_MAX. * * @return Maximum thread count */ int odp_thread_count_max(void); /** + * Maximum control thread count + * + * Otherwise like odp_thread_count_max(), but returns the maximum number of + * control threads (#ODP_THREAD_CONTROL). The returned value is always <= + * odp_thread_count_max(). + * + * @return Maximum control thread count + */ +int odp_thread_control_count_max(void); + +/** + * Maximum worker thread count + * + * Otherwise like odp_thread_count_max(), but returns the maximum number of + * worker threads (#ODP_THREAD_WORKER). The returned value is always <= + * odp_thread_count_max(). + * + * @return Maximum worker thread count + */ +int odp_thread_worker_count_max(void); + +/** * Thread type * * Returns the thread type of the current thread. @@ -101,7 +115,6 @@ int odp_thread_count_max(void); */ odp_thread_type_t odp_thread_type(void); - /** * @} */ |