kernel, posix: Move ready_one_thread() to scheduler

The POSIX layer had a simple ready_one_thread() utility.  Move this to
the scheduler API (with a prepended underscore -- it's an internal
API) so that it can be synchronized along with the rest of the
scheduler.

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
This commit is contained in:
Andy Ross 2018-04-11 08:21:26 -07:00 committed by Anas Nashif
commit 8a4b2e8cf2
4 changed files with 12 additions and 17 deletions

View file

@ -509,6 +509,14 @@ static inline struct k_thread *_unpend1_no_timeout(_wait_q_t *wait_q)
return thread;
}
static inline void _ready_one_thread(_wait_q_t *wq)
{
struct k_thread *th = _unpend_first_thread(wq);
if (th) {
_ready_thread(th);
}
}
#ifdef CONFIG_USERSPACE
/**

View file

@ -9,8 +9,6 @@
#include <ksched.h>
#include <wait_q.h>
void ready_one_thread(_wait_q_t *wq);
int pthread_barrier_wait(pthread_barrier_t *b)
{
int key = irq_lock();
@ -21,7 +19,7 @@ int pthread_barrier_wait(pthread_barrier_t *b)
b->count = 0;
while (!sys_dlist_is_empty(&b->wait_q)) {
ready_one_thread(&b->wait_q);
_ready_one_thread(&b->wait_q);
}
return _reschedule(key);
} else {

View file

@ -10,15 +10,6 @@
#include <posix/pthread.h>
#include <posix/time.h>
void ready_one_thread(_wait_q_t *wq)
{
struct k_thread *th = _unpend_first_thread(wq);
if (th) {
_ready_thread(th);
}
}
s64_t timespec_to_timeoutms(const struct timespec *abstime)
{
s64_t milli_secs;

View file

@ -9,8 +9,6 @@
#include <wait_q.h>
#include <posix/pthread.h>
void ready_one_thread(_wait_q_t *wq);
static int cond_wait(pthread_cond_t *cv, pthread_mutex_t *mut, int timeout)
{
__ASSERT(mut->sem->count == 0, "");
@ -18,7 +16,7 @@ static int cond_wait(pthread_cond_t *cv, pthread_mutex_t *mut, int timeout)
int ret, key = irq_lock();
mut->sem->count = 1;
ready_one_thread(&mut->sem->wait_q);
_ready_one_thread(&mut->sem->wait_q);
ret = _pend_current_thread(key, &cv->wait_q, timeout);
/* FIXME: this extra lock (and the potential context switch it
@ -49,7 +47,7 @@ int pthread_cond_signal(pthread_cond_t *cv)
{
int key = irq_lock();
ready_one_thread(&cv->wait_q);
_ready_one_thread(&cv->wait_q);
_reschedule(key);
return 0;
@ -60,7 +58,7 @@ int pthread_cond_broadcast(pthread_cond_t *cv)
int key = irq_lock();
while (!sys_dlist_is_empty(&cv->wait_q)) {
ready_one_thread(&cv->wait_q);
_ready_one_thread(&cv->wait_q);
}
_reschedule(key);