pthread_attr.c 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615
  1. /*
  2. * Copyright (c) 2006-2023, RT-Thread Development Team
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. *
  6. * Change Logs:
  7. * Date Author Notes
  8. * 2010-10-26 Bernard the first version
  9. */
  10. #include <rtthread.h>
  11. #include "pthread.h"
  12. #include "sched.h"
  13. #include <string.h>
  14. #define DEFAULT_STACK_SIZE 2048
  15. #define DEFAULT_PRIORITY (RT_THREAD_PRIORITY_MAX/2 + RT_THREAD_PRIORITY_MAX/4)
  16. const pthread_attr_t pthread_default_attr =
  17. {
  18. 0, /* stack base */
  19. DEFAULT_STACK_SIZE, /* stack size */
  20. PTHREAD_INHERIT_SCHED, /* Inherit parent prio/policy */
  21. SCHED_FIFO, /* scheduler policy */
  22. {
  23. DEFAULT_PRIORITY, /* scheduler priority */
  24. },
  25. PTHREAD_CREATE_JOINABLE, /* detach state */
  26. };
  27. /**
  28. * @brief This function will initialize thread attributes object.
  29. *
  30. * @note The pthread_attr_t type should be treated as opaque: any access to the object other
  31. * than via pthreads functions is nonportable and produces undefined results.
  32. * The resulting attribute object (possibly modified by setting individual attribute values),
  33. * when used by pthread_create(), defines the attributes of the thread created. A single attributes
  34. * object can be used in multiple simultaneous calls to pthread_create().
  35. *
  36. * @see pthread_create()
  37. *
  38. * @param attr is a thread attributes object.
  39. *
  40. * @return Upon successful completion, pthread_attr_init() return a value of 0.
  41. * Otherwise, it means that the event detach failed.
  42. *
  43. * @warning This function will fail if attr is null.
  44. */
  45. int pthread_attr_init(pthread_attr_t *attr)
  46. {
  47. RT_ASSERT(attr != RT_NULL);
  48. *attr = pthread_default_attr;
  49. return 0;
  50. }
  51. RTM_EXPORT(pthread_attr_init);
  52. /**
  53. * @brief This function will destroy thread attributes object.
  54. *
  55. * @note When a thread attributes object is no longer required, it should be destroyed
  56. * using the pthread_attr_destroy() function. Destroying a thread attributes object
  57. * has no effect on threads that were created using that object.
  58. * Once a thread attributes object has been destroyed, it can be reinitialized using pthread_attr_init().
  59. * Any other use of a destroyed thread attributes object has undefined results.
  60. *
  61. * @see pthread_attr_init(), pthread_attr_getdetachstate(), pthread_create()
  62. *
  63. * @param attr is a thread attributes object.
  64. *
  65. * @return Upon successful completion, pthread_attr_destroy() and shall return a value of 0;
  66. * Otherwise, an error number shall be returned to indicate the error.
  67. *
  68. * @warning This function will fail if attr is null.
  69. */
  70. int pthread_attr_destroy(pthread_attr_t *attr)
  71. {
  72. RT_ASSERT(attr != RT_NULL);
  73. memset(attr, 0, sizeof(pthread_attr_t));
  74. return 0;
  75. }
  76. RTM_EXPORT(pthread_attr_destroy);
  77. /**
  78. * @brief This function set detach state attribute in thread attributes object.
  79. *
  80. * @note This function sets the detach state attribute of the thread attributes object
  81. * referred to by attr to the value specified in detachstate. The detach state
  82. * attribute determines whether a thread created using the thread attributes
  83. * object attr will be created in a joinable or a detached state.
  84. *
  85. * @see pthread_attr_init(), pthread_create(), pthread_detach(), pthread_join(), pthreads()
  86. *
  87. * @param attr is a thread attributes object.
  88. *
  89. * @param state is attribute in the attr object.
  90. * attribute controls whether the thread is created in a detached state.
  91. * The detachstate can be ONE of the following values:
  92. *
  93. * PTHREAD_CREATE_DETACHED It causes all threads created with attr to be in the detached state.
  94. *
  95. * PTHREAD_CREATE_JOINABLE Default value, it causes all threads created with attr to be in the joinable state.
  96. *
  97. * @return Upon successful completion, pthread_attr_setdetachstate() and return a value of 0.
  98. * Otherwise, an error number is returned to indicate the error.
  99. *
  100. * @warning The pthread_attr_setdetachstate() function will fail if:
  101. * [EINVAL]
  102. * The value of detach state was not valid
  103. */
  104. int pthread_attr_setdetachstate(pthread_attr_t *attr, int state)
  105. {
  106. RT_ASSERT(attr != RT_NULL);
  107. if (state != PTHREAD_CREATE_JOINABLE && state != PTHREAD_CREATE_DETACHED)
  108. return EINVAL;
  109. attr->detachstate = state;
  110. return 0;
  111. }
  112. RTM_EXPORT(pthread_attr_setdetachstate);
  113. /**
  114. * @brief This function get detach state attribute in thread attributes object.
  115. *
  116. * @note The detachstate attribute controls whether the thread is created in a detached state.
  117. * If the thread is created detached, then use of the ID of the newly created thread by
  118. * the pthread_detach() or pthread_join() function is an error.
  119. *
  120. * @see pthread_attr_destroy(), pthread_attr_getstackaddr(), pthread_attr_getstacksize(), pthread_create()
  121. *
  122. * @param attr is a thread attributes object.
  123. *
  124. * @param state is attribute in the attr object.
  125. * attribute controls whether the thread is created in a detached state.
  126. * The detachstate can be ONE of the following values:
  127. *
  128. * PTHREAD_CREATE_DETACHED It causes all threads created with attr to be in the detached state.
  129. *
  130. * PTHREAD_CREATE_JOINABLE Default value, it causes all threads created with attr to be in the joinable state.
  131. *
  132. * @return Upon successful completion, pthread_attr_getdetachstate() and shall return a value of 0;
  133. * otherwise, an error number shall be returned to indicate the error.
  134. *
  135. * The pthread_attr_getdetachstate() function stores the value of the detachstate
  136. * attribute in detachstate if successful.
  137. */
  138. int pthread_attr_getdetachstate(pthread_attr_t const *attr, int *state)
  139. {
  140. RT_ASSERT(attr != RT_NULL);
  141. *state = (int)attr->detachstate;
  142. return 0;
  143. }
  144. RTM_EXPORT(pthread_attr_getdetachstate);
  145. /**
  146. * @brief This function sets schedpolicy attribute.
  147. *
  148. * @note The function function sets the scheduling policy attribute of the thread
  149. * attributes object referred to by attr to the value specified in policy.
  150. *
  151. * @see pthread_attr_init(), pthread_attr_setscope(), pthread_attr_setinheritsched(), pthread_attr_setschedparam(), pthread_create()
  152. *
  153. * @param attr is a thread attributes object.
  154. *
  155. * @param policy is attribute in the attr object.
  156. * The policy can be ONE of the following values:
  157. *
  158. * SCHED_FIFO First in-first out scheduling.
  159. *
  160. * SCHED_RR Round-robin scheduling.
  161. *
  162. * SCHED_OTHER Default Linux time-sharing scheduling.
  163. *
  164. * @return On success, these functions return 0.
  165. */
  166. int pthread_attr_setschedpolicy(pthread_attr_t *attr, int policy)
  167. {
  168. RT_ASSERT(attr != RT_NULL);
  169. attr->schedpolicy = policy;
  170. return 0;
  171. }
  172. RTM_EXPORT(pthread_attr_setschedpolicy);
  173. /**
  174. * @brief This function gets schedpolicy attribute.
  175. *
  176. * @note The function gets the schedpolicy attribute in the attr argument.
  177. *
  178. * @see pthread_attr_destroy(), pthread_attr_getscope(), pthread_attr_getinheritsched(), pthread_attr_getschedparam(), pthread_create()
  179. *
  180. * @param attr is a thread attributes object.
  181. *
  182. * @param policy is attribute in the attr object.
  183. * The policy can be ONE of the following values:
  184. *
  185. * SCHED_FIFO First in-first out scheduling.
  186. *
  187. * SCHED_RR Round-robin scheduling.
  188. *
  189. * SCHED_OTHER Default Linux time-sharing scheduling.
  190. *
  191. * @return On success, these functions return 0.
  192. */
  193. int pthread_attr_getschedpolicy(pthread_attr_t const *attr, int *policy)
  194. {
  195. RT_ASSERT(attr != RT_NULL);
  196. *policy = (int)attr->schedpolicy;
  197. return 0;
  198. }
  199. RTM_EXPORT(pthread_attr_getschedpolicy);
  200. /**
  201. * @brief This function set the scheduling parameter attributes in the attr argument.
  202. * @see pthread_attr_init(), pthread_attr_setscope(), pthread_attr_setinheritsched(), pthread_attr_setschedpolicy()
  203. *
  204. * @param attr is a thread attributes object.
  205. *
  206. * @param param is scheduling parameter attributes in the attr argument.
  207. * The contents of the param structure are defined in <pthread.h>.
  208. * For the SCHED_FIFO and SCHED_RR policies, the only required member of param is sched_priority.
  209. *
  210. * @return On success, these functions return 0.
  211. */
  212. int pthread_attr_setschedparam(pthread_attr_t *attr,
  213. struct sched_param const *param)
  214. {
  215. RT_ASSERT(attr != RT_NULL);
  216. RT_ASSERT(param != RT_NULL);
  217. attr->schedparam.sched_priority = param->sched_priority;
  218. return 0;
  219. }
  220. RTM_EXPORT(pthread_attr_setschedparam);
  221. /**
  222. * @brief This function get the scheduling parameter attributes in the attr argument.
  223. * @see pthread_attr_init(), pthread_attr_setscope(), pthread_attr_setinheritsched(), pthread_attr_setschedpolicy()
  224. *
  225. * @param attr is a thread attributes object.
  226. *
  227. * @param param is scheduling parameter attributes in the attr argument.
  228. * The contents of the param structure are defined in <pthread.h>.
  229. * For the SCHED_FIFO and SCHED_RR policies, the only required member of param is sched_priority.
  230. *
  231. * @return On success, these functions return 0.
  232. */
  233. int pthread_attr_getschedparam(pthread_attr_t const *attr,
  234. struct sched_param *param)
  235. {
  236. RT_ASSERT(attr != RT_NULL);
  237. RT_ASSERT(param != RT_NULL);
  238. param->sched_priority = attr->schedparam.sched_priority;
  239. return 0;
  240. }
  241. RTM_EXPORT(pthread_attr_getschedparam);
  242. /**
  243. * @brief This function set the thread creation stacksize attribute in the attr object.
  244. *
  245. * @see pthread_attr_init(), pthread_attr_setstackaddr(), pthread_attr_setdetachstate()
  246. *
  247. * @param attr is a thread attributes object.
  248. *
  249. * @param stack_size is the minimum stack size (in bytes) allocated for the created threads stack.
  250. *
  251. * @return Upon successful completion, This function return a value of 0.
  252. */
  253. int pthread_attr_setstacksize(pthread_attr_t *attr, size_t stack_size)
  254. {
  255. RT_ASSERT(attr != RT_NULL);
  256. attr->stacksize = stack_size;
  257. return 0;
  258. }
  259. RTM_EXPORT(pthread_attr_setstacksize);
  260. /**
  261. * @brief This function get the thread creation stacksize attribute in the attr object.
  262. *
  263. * @see pthread_attr_init(), pthread_attr_getstackaddr(), pthread_attr_getdetachstate()
  264. *
  265. * @param attr is a thread attributes object.
  266. *
  267. * @param stack_size is the minimum stack size (in bytes) allocated for the created threads stack.
  268. *
  269. * @return Upon successful completion, This function return a value of 0.
  270. */
  271. int pthread_attr_getstacksize(pthread_attr_t const *attr, size_t *stack_size)
  272. {
  273. RT_ASSERT(attr != RT_NULL);
  274. *stack_size = attr->stacksize;
  275. return 0;
  276. }
  277. RTM_EXPORT(pthread_attr_getstacksize);
  278. /**
  279. * @brief This function sets the thread creation stackaddr attribute in the attr object.
  280. *
  281. * @see pthread_attr_init(), pthread_attr_setdetachstate(), pthread_attr_setstacksize()
  282. *
  283. * @param attr is a thread attributes object.
  284. *
  285. * @param The stack_addr attribute specifies the location of storage to be used for the created
  286. * thread's stack.
  287. *
  288. * @return Upon successful completion, This function return a value of 0.
  289. */
  290. int pthread_attr_setstackaddr(pthread_attr_t *attr, void *stack_addr)
  291. {
  292. RT_ASSERT(attr != RT_NULL);
  293. return EOPNOTSUPP;
  294. }
  295. RTM_EXPORT(pthread_attr_setstackaddr);
  296. /**
  297. * @brief This function gets the thread creation stackaddr attribute in the attr object.
  298. *
  299. * @see pthread_attr_init(), pthread_attr_setdetachstate(), pthread_attr_setstacksize()
  300. *
  301. * @param attr is a thread attributes object.
  302. *
  303. * @param The stack_addr attribute specifies the location of storage to be used for the created
  304. * thread's stack.
  305. *
  306. * @return Upon successful completion, This function return a value of 0.
  307. */
  308. int pthread_attr_getstackaddr(pthread_attr_t const *attr, void **stack_addr)
  309. {
  310. RT_ASSERT(attr != RT_NULL);
  311. return EOPNOTSUPP;
  312. }
  313. RTM_EXPORT(pthread_attr_getstackaddr);
  314. /**
  315. * @brief This function set the thread creation stack attributes stackaddr and stacksize in the attr object.
  316. *
  317. * @note The stack attributes specify the area of storage to be used for the created thread's stack.
  318. * The base (lowest addressable byte) of the storage shall be stack_base, and the size of the storage
  319. * shall be stack_size bytes.
  320. * All pages within the stack described by stackaddr and stacksize shall be both readable
  321. * and writable by the thread.
  322. *
  323. * @see pthread_attr_destroy, pthread_attr_getdetachstate, pthread_attr_getstacksize, pthread_create
  324. *
  325. * @param attr is a thread attributes object.
  326. *
  327. * @param stack_base is the base (lowest addressable byte) of the storage.
  328. *
  329. * @param stack_size is the size of the storage.
  330. *
  331. * @return Upon successful completion, these functions shall return a value of 0;
  332. * otherwise, an error number shall be returned to indicate the error.
  333. *
  334. * @warning The behavior is undefined if the value specified by the attr argument to or pthread_attr_setstack()
  335. * does not refer to an initialized thread attributes object.
  336. */
  337. int pthread_attr_setstack(pthread_attr_t *attr,
  338. void *stack_base,
  339. size_t stack_size)
  340. {
  341. RT_ASSERT(attr != RT_NULL);
  342. attr->stackaddr = stack_base;
  343. attr->stacksize = RT_ALIGN_DOWN(stack_size, RT_ALIGN_SIZE);
  344. return 0;
  345. }
  346. RTM_EXPORT(pthread_attr_setstack);
  347. /**
  348. * @brief This function shall get the thread creation stack attributes stackaddr and stacksize in the attr object.
  349. *
  350. * @note The stack attributes specify the area of storage to be used for the created thread's stack.
  351. * The base (lowest addressable byte) of the storage shall be stack_base, and the size of the storage
  352. * shall be stack_size bytes.
  353. * All pages within the stack described by stack_base and stack_size shall be both readable
  354. * and writable by the thread.
  355. *
  356. * @see pthread_attr_destroy, pthread_attr_getdetachstate, pthread_attr_getstacksize, pthread_create
  357. *
  358. * @param attr is a thread attributes object.
  359. *
  360. * @param stack_base is the base (lowest addressable byte) of the storage.
  361. *
  362. * @param stack_size is the size of the storage.
  363. *
  364. * @return Upon successful completion, these functions shall return a value of 0;
  365. * otherwise, an error number shall be returned to indicate the error.
  366. * This function shall store the stack attribute values in stack_base and stack_size if successful.
  367. */
  368. int pthread_attr_getstack(pthread_attr_t const *attr,
  369. void **stack_base,
  370. size_t *stack_size)
  371. {
  372. RT_ASSERT(attr != RT_NULL);
  373. *stack_base = attr->stackaddr;
  374. *stack_size = attr->stacksize;
  375. return 0;
  376. }
  377. RTM_EXPORT(pthread_attr_getstack);
  378. /**
  379. * @brief This function shall set the guardsize attribute in the attr object.
  380. *
  381. * @note The guardsize attribute controls the size of the guard area for the created thread's stack.
  382. * The guardsize attribute provides protection against overflow of the stack pointer.
  383. * If a thread's stack is created with guard protection, the implementation allocates extra
  384. * memory at the overflow end of the stack as a buffer against stack overflow of the stack pointer.
  385. * If an application overflows into this buffer an error shall result (possibly in a SIGSEGV signal
  386. * being delivered to the thread).
  387. *
  388. * @see <pthread.h>, <sys/mman.h>
  389. *
  390. * @param attr is a thread attributes object.
  391. *
  392. * @param guard_size is the size of the guard area for the created thread's stack.
  393. *
  394. * @return Upon successful completion, these functions shall return a value of 0;
  395. *
  396. * @warning The guardsize attribute is provided to the application for two reasons:
  397. *
  398. * 1. Overflow protection can potentially result in wasted system resources.
  399. * An application that creates a large number of threads, and which knows its threads
  400. * never overflow their stack, can save system resources by turning off guard areas.
  401. *
  402. * 2. When threads allocate large data structures on the stack, large guard areas may be
  403. * needed to detect stack overflow.
  404. *
  405. * The default size of the guard area is left implementation-defined since on systems
  406. * supporting very large page sizes, the overhead might be substantial if at least one guard
  407. * page is required by default.
  408. */
  409. int pthread_attr_setguardsize(pthread_attr_t *attr, size_t guard_size)
  410. {
  411. return EOPNOTSUPP;
  412. }
  413. /**
  414. * @brief This function get the guardsize attribute in the attr object.
  415. * This attribute shall be returned in the guard_size parameter.
  416. *
  417. * @note The guardsize attribute controls the size of the guard area for the created thread's stack.
  418. * The guardsize attribute provides protection against overflow of the stack pointer.
  419. * If a thread's stack is created with guard protection, the implementation allocates extra
  420. * memory at the overflow end of the stack as a buffer against stack overflow of the stack pointer.
  421. *
  422. * @see <pthread.h>, <sys/mman.h>
  423. *
  424. * @param attr is a thread attributes object.
  425. *
  426. * @param guard_size is the size of the guard area for the created thread's stack.
  427. *
  428. * @return Upon successful completion, these functions shall return a value of 0;
  429. *
  430. * @warning The guardsize attribute is provided to the application for two reasons:
  431. *
  432. * 1. Overflow protection can potentially result in wasted system resources.
  433. * An application that creates a large number of threads, and which knows its threads
  434. * never overflow their stack, can save system resources by turning off guard areas.
  435. *
  436. * 2. When threads allocate large data structures on the stack, large guard areas may be
  437. * needed to detect stack overflow.
  438. *
  439. * The default size of the guard area is left implementation-defined since on systems
  440. * supporting very large page sizes, the overhead might be substantial if at least one guard
  441. * page is required by default.
  442. */
  443. int pthread_attr_getguardsize(pthread_attr_t const *attr, size_t *guard_size)
  444. {
  445. return EOPNOTSUPP;
  446. }
  447. RTM_EXPORT(pthread_attr_getguardsize);
  448. /**
  449. * @brief This function sets inherit-scheduler attribute in thread attributes object.
  450. *
  451. * @note The function sets the inherit-scheduler attribute of the thread attributes object
  452. * referred to by attr to the value specified in inheritsched.
  453. * The inherit-scheduler attribute determines whether a thread created using the thread
  454. * attributes object attr will inherit its scheduling attributes from the calling thread
  455. * or whether it will take them from attr.
  456. *
  457. * @see pthread_attr_init(), pthread_attr_setschedpolicy(), pthread_attr_setschedparam()
  458. *
  459. * @param attr is a thread attributes object.
  460. *
  461. * @param inheritsched the inheritsched attribute determines how the other scheduling attributes of the created thread are to be set:
  462. * The policy can be ONE of the following values:
  463. *
  464. * PTHREAD_INHERIT_SCHED Specifies that the scheduling policy and associated attributes are
  465. * to be inherited from the creating thread, and the scheduling attributes
  466. * in this attr argument are to be ignored.
  467. *
  468. * PTHREAD_EXPLICIT_SCHED Specifies that the scheduling policy and associated attributes are to be
  469. * set to the corresponding values from this attribute object.
  470. *
  471. * @return Upon successful completion, these functions shall return a value of 0;
  472. */
  473. int pthread_attr_setinheritsched(pthread_attr_t *attr, int inheritsched)
  474. {
  475. RT_ASSERT(attr != RT_NULL);
  476. attr->inheritsched = inheritsched;
  477. return 0;
  478. }
  479. RTM_EXPORT(pthread_attr_setinheritsched);
  480. /**
  481. * @brief This function get and set the inheritsched attribute in the attr argument.
  482. *
  483. * @note The function sets the inherit-scheduler attribute of the thread attributes object
  484. * referred to by attr to the value specified in inheritsched.
  485. * The inherit-scheduler attribute determines whether a thread created using the thread
  486. * attributes object attr will inherit its scheduling attributes from the calling thread
  487. * or whether it will take them from attr.
  488. *
  489. * @see pthread_attr_init(), pthread_attr_getschedpolicy(), pthread_attr_getschedparam()
  490. *
  491. * @param attr is a thread attributes object.
  492. *
  493. * @param inheritsched the inheritsched attribute determines how the other scheduling attributes of the created thread are to be set:
  494. * The inheritsched can be ONE of the following values:
  495. *
  496. * PTHREAD_INHERIT_SCHED Specifies that the scheduling policy and associated attributes are
  497. * to be inherited from the creating thread, and the scheduling attributes
  498. * in this attr argument are to be ignored.
  499. *
  500. * PTHREAD_EXPLICIT_SCHED Specifies that the scheduling policy and associated attributes are to be
  501. * set to the corresponding values from this attribute object.
  502. *
  503. * @return Upon successful completion, these functions shall return a value of 0;
  504. */
  505. int pthread_attr_getinheritsched(const pthread_attr_t *attr, int *inheritsched)
  506. {
  507. RT_ASSERT(attr != RT_NULL);
  508. *inheritsched = attr->inheritsched;
  509. return 0;
  510. }
  511. RTM_EXPORT(pthread_attr_getinheritsched);
  512. /**
  513. * @brief This function set contentionscope attribute.
  514. *
  515. * @note The function are used to set the contentionscope attribute in the attr object.
  516. *
  517. * @param attr is a thread attributes object.
  518. *
  519. * @param scope is the value of contentionscope attribute.
  520. * The scope can be ONE of the following values:
  521. *
  522. * PTHREAD_SCOPE_SYSTEM signifying system scheduling contention scope.
  523. *
  524. * PTHREAD_SCOPE_PROCESS signifying process scheduling contention scope.
  525. *
  526. * @return Upon successful completion, these functions shall return a value of 0;
  527. */
  528. int pthread_attr_setscope(pthread_attr_t *attr, int scope)
  529. {
  530. if (scope == PTHREAD_SCOPE_SYSTEM)
  531. return 0;
  532. if (scope == PTHREAD_SCOPE_PROCESS)
  533. return EOPNOTSUPP;
  534. return EINVAL;
  535. }
  536. RTM_EXPORT(pthread_attr_setscope);
  537. /**
  538. * @brief This function get contentionscope attribute.
  539. *
  540. * @note The function are used to get the contentionscope attribute in the attr object.
  541. *
  542. * @param attr is a thread attributes object.
  543. *
  544. * @param scope is the value of contentionscope attribute.
  545. * The scope can be ONE of the following values:
  546. *
  547. * PTHREAD_SCOPE_SYSTEM signifying system scheduling contention scope.
  548. *
  549. * PTHREAD_SCOPE_PROCESS signifying process scheduling contention scope.
  550. *
  551. * @return Upon successful completion, these functions shall return a value of 0;
  552. */
  553. int pthread_attr_getscope(pthread_attr_t const *attr, int *scope)
  554. {
  555. return PTHREAD_SCOPE_SYSTEM;
  556. }
  557. RTM_EXPORT(pthread_attr_getscope);