Kevin Peng | 477fa94 | 2019-07-29 10:55:17 +0800 | [diff] [blame^] | 1 | /* |
| 2 | * Copyright (c) 2017-2019, Arm Limited. All rights reserved. |
| 3 | * |
| 4 | * SPDX-License-Identifier: BSD-3-Clause |
| 5 | * |
| 6 | */ |
| 7 | |
| 8 | #ifndef __OS_WRAPPER_THREAD_H__ |
| 9 | #define __OS_WRAPPER_THREAD_H__ |
| 10 | |
| 11 | #ifdef __cplusplus |
| 12 | extern "C" { |
| 13 | #endif |
| 14 | |
| 15 | #include "common.h" |
| 16 | |
| 17 | /* prototype for the thread entry function */ |
| 18 | typedef void (*os_wrapper_thread_func) (void *argument); |
| 19 | |
| 20 | /** |
| 21 | * \brief Creates a new thread |
| 22 | * |
| 23 | * \param[in] name Name of the thread |
| 24 | * \param[in] stack_size Size of stack to be allocated for this thread. It can |
| 25 | * be \ref OS_WRAPPER_DEFAULT_STACK_SIZE to use the |
| 26 | * default value provided by the underlying RTOS |
| 27 | * \param[in] func Pointer to the function invoked by thread |
| 28 | * \param[in] arg Argument to pass to the function invoked by thread |
| 29 | * \param[in] priority Initial thread priority |
| 30 | * |
| 31 | * \return Returns thread ID, or \ref OS_WRAPPER_ERROR in case of error |
| 32 | */ |
| 33 | uint32_t os_wrapper_thread_new(const char *name, int32_t stack_size, |
| 34 | os_wrapper_thread_func func, void *arg, |
| 35 | uint32_t priority); |
| 36 | /** |
| 37 | * \brief Gets current thread ID |
| 38 | * |
| 39 | * \return Returns thread ID, or \ref OS_WRAPPER_ERROR in case of error |
| 40 | */ |
| 41 | uint32_t os_wrapper_thread_get_id(void); |
| 42 | |
| 43 | /** |
| 44 | * \brief Gets thread priority |
| 45 | * |
| 46 | * \param[in] id Thread ID |
| 47 | * |
| 48 | * \return Returns thread priority value, or \ref OS_WRAPPER_ERROR in case of |
| 49 | * error |
| 50 | */ |
| 51 | uint32_t os_wrapper_thread_get_priority(uint32_t id); |
| 52 | |
| 53 | /** |
| 54 | * \brief Exits the calling thread |
| 55 | */ |
| 56 | void os_wrapper_thread_exit(void); |
| 57 | |
| 58 | #ifdef __cplusplus |
| 59 | } |
| 60 | #endif |
| 61 | |
| 62 | #endif /* __OS_WRAPPER_THREAD_H__ */ |