Skip to content

Commit

Permalink
kernel: Remove references to _EXPIRED
Browse files Browse the repository at this point in the history
The _EXPIRED macro is no longer necessary. It is a relic of an older
timeout processing algorithm from several years ago.

Signed-off-by: Peter Mitsis <peter.mitsis@intel.com>
  • Loading branch information
peter-mitsis authored and cfriedt committed Sep 15, 2023
1 parent 798b863 commit c7255cf
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 65 deletions.
3 changes: 0 additions & 3 deletions include/zephyr/kernel.h
Original file line number Diff line number Diff line change
Expand Up @@ -676,9 +676,6 @@ static inline k_ticks_t z_impl_k_thread_timeout_remaining_ticks(
* @cond INTERNAL_HIDDEN
*/

/* timeout has timed out and is not on _timeout_q anymore */
#define _EXPIRED (-2)

struct _static_thread_data {
struct k_thread *init_thread;
k_thread_stack_t *init_stack;
Expand Down
9 changes: 0 additions & 9 deletions kernel/include/ksched.h
Original file line number Diff line number Diff line change
Expand Up @@ -268,15 +268,6 @@ static ALWAYS_INLINE void z_sched_unlock_no_reschedule(void)
++_current->base.sched_locked;
}

static ALWAYS_INLINE bool z_is_thread_timeout_expired(struct k_thread *thread)
{
#ifdef CONFIG_SYS_CLOCK_EXISTS
return thread->base.timeout.dticks == _EXPIRED;
#else
return 0;
#endif
}

/*
* APIs for working with the Zephyr kernel scheduler. Intended for use in
* management of IPC objects, either in the core kernel or other IPC
Expand Down
4 changes: 0 additions & 4 deletions kernel/poll.c
Original file line number Diff line number Diff line change
Expand Up @@ -271,10 +271,6 @@ static int signal_poller(struct k_poll_event *event, uint32_t state)
return 0;
}

if (z_is_thread_timeout_expired(thread)) {
return -EAGAIN;
}

z_unpend_thread(thread);
arch_thread_return_value_set(thread,
state == K_POLL_STATE_CANCELLED ? -EINTR : 0);
Expand Down
49 changes: 0 additions & 49 deletions tests/kernel/poll/src/test_poll.c
Original file line number Diff line number Diff line change
Expand Up @@ -787,52 +787,3 @@ ZTEST(poll_api_1cpu, test_poll_zero_events)

zassert_equal(k_poll(&event, 0, K_MSEC(50)), -EAGAIN);
}

/* subthread entry */
void polling_event(void *p1, void *p2, void *p3)
{
k_poll(p1, 1, K_FOREVER);
}

/**
* @brief Detect is_polling is false in signal_poll_event()
*
* @details
* Define and initialize a signal event, and spawn a thread to
* poll event, and set dticks as invalid, check if the value
* of is_polling in function signal_poll_event().
*
* @ingroup kernel_poll_tests
*/
ZTEST(poll_api_1cpu, test_detect_is_polling)
{
k_poll_signal_init(&test_signal);

struct k_thread *p = &test_thread;
struct k_poll_event events[1] = {
K_POLL_EVENT_INITIALIZER(K_POLL_TYPE_SIGNAL,
K_POLL_MODE_NOTIFY_ONLY,
&test_signal),
};

k_tid_t tid = k_thread_create(&test_thread, test_stack,
K_THREAD_STACK_SIZEOF(test_stack), polling_event,
events, NULL, NULL, K_PRIO_PREEMPT(0),
K_INHERIT_PERMS, K_NO_WAIT);

/* Set up the thread timeout value to check if
* what happened if dticks is invalid.
*/
p->base.timeout.dticks = _EXPIRED;
/* Wait for register event successfully */
k_sleep(K_MSEC(50));

/* Raise a signal */
int ret = k_poll_signal_raise(&test_signal, 0x1337);

zassert_true(ret == -EAGAIN, "thread expired failed\n");
zassert_true(events[0].poller->is_polling == false,
"the value of is_polling is invalid\n");

k_thread_abort(tid);
}

0 comments on commit c7255cf

Please sign in to comment.