Skip to content

kernel/sched: More nonatomic swap fixes #13770

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 27, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions kernel/sched.c
Original file line number Diff line number Diff line change
Expand Up @@ -619,6 +619,13 @@ ALWAYS_INLINE void _priq_dumb_add(sys_dlist_t *pq, struct k_thread *thread)

void _priq_dumb_remove(sys_dlist_t *pq, struct k_thread *thread)
{
#if defined(CONFIG_SWAP_NONATOMIC) && defined(CONFIG_SCHED_DUMB)
if (pq == &_kernel.ready_q.runq && thread == _current &&
_is_thread_prevented_from_running(thread)) {
return;
}
#endif

__ASSERT_NO_MSG(!_is_idle(thread));

sys_dlist_remove(&thread->base.qnode_dlist);
Expand Down Expand Up @@ -676,6 +683,12 @@ void _priq_rb_add(struct _priq_rb *pq, struct k_thread *thread)

void _priq_rb_remove(struct _priq_rb *pq, struct k_thread *thread)
{
#if defined(CONFIG_SWAP_NONATOMIC) && defined(CONFIG_SCHED_SCALABLE)
if (pq == &_kernel.ready_q.runq && thread == _current &&
_is_thread_prevented_from_running(thread)) {
return;
}
#endif
__ASSERT_NO_MSG(!_is_idle(thread));

rb_remove(&pq->tree, &thread->base.qnode_rb);
Expand Down Expand Up @@ -712,6 +725,12 @@ ALWAYS_INLINE void _priq_mq_add(struct _priq_mq *pq, struct k_thread *thread)

ALWAYS_INLINE void _priq_mq_remove(struct _priq_mq *pq, struct k_thread *thread)
{
#if defined(CONFIG_SWAP_NONATOMIC) && defined(CONFIG_SCHED_MULTIQ)
if (pq == &_kernel.ready_q.runq && thread == _current &&
_is_thread_prevented_from_running(thread)) {
return;
}
#endif
int priority_bit = thread->base.prio - K_HIGHEST_THREAD_PRIO;

sys_dlist_remove(&thread->base.qnode_dlist);
Expand Down Expand Up @@ -893,6 +912,9 @@ s32_t _impl_k_sleep(s32_t duration)
struct k_spinlock local_lock = {};
k_spinlock_key_t key = k_spin_lock(&local_lock);

#if defined(CONFIG_TIMESLICING) && defined(CONFIG_SWAP_NONATOMIC)
pending_current = _current;
#endif
_remove_thread_from_ready_q(_current);
_add_thread_timeout(_current, ticks);

Expand Down