kernel: Add _unpend_all convenience wrapper to scheduler API

Refactoring.  Mempool wants to unpend all threads at once.  It's
cleaner to do this in the scheduler instead of the IPC code.

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
This commit is contained in:
Andy Ross 2018-05-10 09:45:42 -07:00 committed by Anas Nashif
parent 39f396a8ad
commit 4ca0e07088
3 changed files with 14 additions and 7 deletions

View file

@ -43,6 +43,7 @@ void _pend_thread(struct k_thread *thread, _wait_q_t *wait_q, s32_t timeout);
int _reschedule(int key);
struct k_thread *_unpend_first_thread(_wait_q_t *wait_q);
void _unpend_thread(struct k_thread *thread);
void _unpend_all(_wait_q_t *wait_q);
void _thread_priority_set(struct k_thread *thread, int prio);
void *_get_next_switch_handle(void *interrupted);
struct k_thread *_find_first_thread_to_unpend(_wait_q_t *wait_q,

View file

@ -99,13 +99,7 @@ void k_mem_pool_free_id(struct k_mem_block_id *id)
*/
key = irq_lock();
while (!sys_dlist_is_empty(&p->wait_q)) {
struct k_thread *th = (void *)sys_dlist_peek_head(&p->wait_q);
_unpend_thread(th);
_ready_thread(th);
need_sched = 1;
}
_unpend_all(&p->wait_q);
if (need_sched && !_is_in_isr()) {
_reschedule(key);

View file

@ -337,6 +337,18 @@ struct k_thread *_unpend_first_thread(_wait_q_t *wait_q)
return t;
}
void _unpend_all(_wait_q_t *waitq)
{
while (!sys_dlist_is_empty(waitq)) {
struct k_thread *th = (void *)sys_dlist_peek_head(waitq);
_unpend_thread(th);
_ready_thread(th);
need_sched = 1;
}
}
/* Block the current thread and swap to the next. Releases the
* irq_lock, does a _Swap and returns the return value set at wakeup
* time