Skip to content

Commit 31a9804

Browse files
authored
Implement thread suspend state mapping logic
Map suspend_flag to corresponding thread suspend state values and update suspend state if stricter flag is requested.
1 parent 03881b0 commit 31a9804

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

src/thread.c

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -958,8 +958,25 @@ rt_err_t rt_thread_suspend_to_list(rt_thread_t thread, rt_list_t *susp_list, int
958958
rt_sched_thread_timer_stop(thread);
959959

960960
}
961-
if (stat < suspend_flag)
961+
/* Map suspend_flag to corresponding thread suspend state value */
962+
rt_uint8_t new_suspend_state;
963+
switch (suspend_flag)
962964
{
965+
case RT_INTERRUPTIBLE:
966+
new_suspend_state = RT_THREAD_SUSPEND_INTERRUPTIBLE;
967+
break;
968+
case RT_KILLABLE:
969+
new_suspend_state = RT_THREAD_SUSPEND_KILLABLE;
970+
break;
971+
case RT_UNINTERRUPTIBLE:
972+
default:
973+
new_suspend_state = RT_THREAD_SUSPEND_UNINTERRUPTIBLE;
974+
break;
975+
}
976+
/* Compare the suspend state portion of stat with the new suspend state */
977+
if (stat < new_suspend_state)
978+
{
979+
/* Update if a stricter suspend_flag is requested */
963980
/* Update if suspend_flag is stricter */
964981
_thread_set_suspend_state(thread, suspend_flag);
965982
}

0 commit comments

Comments
 (0)