esp_pthread.h 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. // Copyright 2018 Espressif Systems (Shanghai) PTE LTD
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. // http://www.apache.org/licenses/LICENSE-2.0
  7. //
  8. // Unless required by applicable law or agreed to in writing, software
  9. // distributed under the License is distributed on an "AS IS" BASIS,
  10. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  11. // See the License for the specific language governing permissions and
  12. // limitations under the License.
  13. #pragma once
  14. #ifdef __cplusplus
  15. extern "C" {
  16. #endif
  17. #ifndef PTHREAD_STACK_MIN
  18. #define PTHREAD_STACK_MIN CONFIG_PTHREAD_STACK_MIN
  19. #endif
  20. /** pthread configuration structure that influences pthread creation */
  21. typedef struct {
  22. size_t stack_size; ///< the stack size of the pthread
  23. size_t prio; ///< the thread's priority
  24. bool inherit_cfg; ///< inherit this configuration further
  25. } esp_pthread_cfg_t;
  26. /**
  27. * @brief Configure parameters for creating pthread
  28. *
  29. * This API allows you to configure how the subsequent
  30. * pthread_create() call will behave. This call can be used to setup
  31. * configuration parameters like stack size, priority, configuration
  32. * inheritance etc.
  33. *
  34. * If the 'inherit' flag in the configuration structure is enabled,
  35. * then the same configuration is also inherited in the thread
  36. * subtree.
  37. *
  38. * @note Passing non-NULL attributes to pthread_create() will override
  39. * the stack_size parameter set using this API
  40. *
  41. * @param cfg The pthread config parameters
  42. *
  43. * @return
  44. * - ESP_OK if configuration was successfully set
  45. * - ESP_ERR_NO_MEM if out of memory
  46. * - ESP_ERR_INVALID_ARG if stack_size is less than PTHREAD_STACK_MIN
  47. */
  48. esp_err_t esp_pthread_set_cfg(const esp_pthread_cfg_t *cfg);
  49. /**
  50. * @brief Get current pthread creation configuration
  51. *
  52. * This will retrieve the current configuration that will be used for
  53. * creating threads.
  54. *
  55. * @param p Pointer to the pthread config structure that will be
  56. * updated with the currently configured parameters
  57. *
  58. * @return
  59. * - ESP_OK if the configuration was available
  60. * - ESP_ERR_NOT_FOUND if a configuration wasn't previously set
  61. */
  62. esp_err_t esp_pthread_get_cfg(esp_pthread_cfg_t *p);
  63. #ifdef __cplusplus
  64. }
  65. #endif