esp_pthread.h 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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. #include <pthread.h>
  14. /** pthread configuration structure that influences pthread creation */
  15. typedef struct {
  16. size_t stack_size; ///< the stack size of the pthread
  17. size_t prio; ///< the thread's priority
  18. bool inherit_cfg; ///< inherit this configuration further
  19. } esp_pthread_cfg_t;
  20. /**
  21. * @brief Configure parameters for creating pthread
  22. *
  23. * This API allows you to configure how the subsequent
  24. * pthread_create() call will behave. This call can be used to setup
  25. * configuration parameters like stack size, priority, configuration
  26. * inheritance etc.
  27. *
  28. * If the 'inherit' flag in the configuration structure is enabled,
  29. * then the same configuration is also inherited in the thread
  30. * subtree.
  31. *
  32. * @param cfg The pthread config parameters
  33. *
  34. * @return
  35. * - ESP_OK if configuration was successfully set
  36. * - ESP_ERR_NO_MEM if out of memory
  37. */
  38. esp_err_t esp_pthread_set_cfg(const esp_pthread_cfg_t *cfg);
  39. /**
  40. * @brief Get current pthread creation configuration
  41. *
  42. * This will retrieve the current configuration that will be used for
  43. * creating threads.
  44. *
  45. * @param p Pointer to the pthread config structure that will be
  46. * updated with the currently configured parameters
  47. *
  48. * @return
  49. * - ESP_OK if the configuration was available
  50. * - ESP_ERR_NOT_FOUND if a configuration wasn't previously set
  51. */
  52. esp_err_t esp_pthread_get_cfg(esp_pthread_cfg_t *p);