Skip to content

Commit 8f899db

Browse files
Chris Friedtcfriedt
authored andcommitted
posix: sched: move sched_yield() to pthread.c
The `sched_yield()` function was originally included to facilitate the of POSIX_REALTIME and POSIX_THREADS_EXT Option Groups in Issue 5. It was then marked as part of the _POSIX_PROCESS_SCHEDULING Option in Issue 6, but then was not clearly marked as part of the POSIX_THREADS(_BASE) Option Group until Issue 7. Moving it to `pthread.c` (and making it a function with regular linkage rather than inline) ensures that it will be available with the `POSIX_THREADS` Option Group. For more information, please see `POSIX_THREADS_BASE` in https://pubs.opengroup.org/onlinepubs/9699919799/xrat/\ V4_subprofiles.html and https://pubs.opengroup.org/onlinepubs/9799919799/xrat/\ V4_subprofiles.html Signed-off-by: Chris Friedt <cfriedt@tenstorrent.com>
1 parent c01c4e9 commit 8f899db

File tree

3 files changed

+24
-7
lines changed

3 files changed

+24
-7
lines changed

include/zephyr/posix/sched.h

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,7 @@ struct sched_param {
4040
*
4141
* See IEEE 1003.1
4242
*/
43-
static inline int sched_yield(void)
44-
{
45-
k_yield();
46-
return 0;
47-
}
43+
int sched_yield(void);
4844

4945
int sched_get_priority_min(int policy);
5046
int sched_get_priority_max(int policy);

lib/posix/options/Kconfig.pthread

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,23 @@
77
menuconfig POSIX_THREADS
88
bool "POSIX thread support"
99
help
10-
Select 'y' here to enable POSIX threads, mutexes, condition variables, and thread-specific
11-
storage.
10+
Select 'y' here to enable POSIX threads, mutexes, condition variables, and
11+
thread-specific storage.
12+
13+
This option makes the following functions available:
14+
pthread_atfork(), pthread_attr_destroy(), pthread_attr_getdetachstate(),
15+
pthread_attr_getschedparam(), pthread_attr_init(), pthread_attr_setdetachstate(),
16+
pthread_attr_setschedparam(), pthread_cancel(), pthread_cleanup_pop(),
17+
pthread_cleanup_push(), pthread_cond_broadcast(), pthread_cond_destroy(),
18+
pthread_cond_init(), pthread_cond_signal(), pthread_cond_timedwait(),
19+
pthread_cond_wait(), pthread_condattr_destroy(), pthread_condattr_init(),
20+
pthread_create(), pthread_detach(), pthread_equal(), pthread_exit(),
21+
pthread_getspecific(), pthread_join(), pthread_key_create(), pthread_key_delete(),
22+
pthread_kill(), pthread_mutex_destroy(), pthread_mutex_init(), pthread_mutex_lock(),
23+
pthread_mutex_timedlock(), pthread_mutex_trylock(), pthread_mutex_unlock(),
24+
pthread_mutexattr_destroy(), pthread_mutexattr_init(), pthread_once(), pthread_self(),
25+
pthread_setcancelstate(), pthread_setcanceltype(), pthread_setspecific(),
26+
pthread_sigmask(), pthread_testcancel(), and sched_yield().
1227

1328
For more information please see
1429
https://pubs.opengroup.org/onlinepubs/9699919799/xrat/V4_subprofiles.html

lib/posix/options/pthread.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1551,3 +1551,9 @@ static int posix_thread_pool_init(void)
15511551
return 0;
15521552
}
15531553
SYS_INIT(posix_thread_pool_init, PRE_KERNEL_1, 0);
1554+
1555+
int sched_yield(void)
1556+
{
1557+
k_yield();
1558+
return 0;
1559+
}

0 commit comments

Comments
 (0)