@@ -942,39 +942,42 @@ rt_err_t rt_thread_suspend_to_list(rt_thread_t thread, rt_list_t *susp_list, int
942942 /* parameter check */
943943 RT_ASSERT (thread != RT_NULL );
944944 RT_ASSERT (rt_object_get_type ((rt_object_t )thread ) == RT_Object_Class_Thread );
945-
945+
946946 LOG_D ("thread suspend: %s" , thread -> parent .name );
947- RT_ASSERT (thread == rt_thread_self ());
948947
949948 rt_sched_lock (& slvl );
950949
951950 stat = rt_sched_thread_get_stat (thread );
951+ /* Already suspended, just set the status to success. */
952952 if (stat & RT_THREAD_SUSPEND_MASK )
953953 {
954- /* Already manually suspended, just set the status to success. */
955- if (RT_SCHED_CTX (thread ).sched_flag_ttmr_set == 0 )
954+ if (RT_SCHED_CTX (thread ).sched_flag_ttmr_set == 1 )
956955 {
957- /* Update if a pending flag needs */
958- if ((stat & RT_THREAD_STAT_MASK ) < suspend_flag )
959- {
960- _thread_set_suspend_state (thread , suspend_flag );
961- }
962-
963- rt_sched_unlock (slvl );
964- return RT_EOK ;
956+ /* The new suspend operation will halt the tick timer. */
957+ LOG_D ("Thread [%s]'s timer has been halted.\n" , thread -> parent .name );
958+ rt_sched_thread_timer_stop (thread );
959+
965960 }
966- /* Manual suspension overrides delayed suspension. */
967- else
961+ if (stat < suspend_flag )
968962 {
969- LOG_D ("thread suspend: converting delay suspend to manual suspend" );
963+ /* Update if a suspend_flag flag stricter */
964+ _thread_set_suspend_state (thread , suspend_flag );
970965 }
966+
967+ rt_sched_unlock (slvl );
968+ return RT_EOK ;
971969 }
972970 else if ((stat != RT_THREAD_READY ) && (stat != RT_THREAD_RUNNING ))
973971 {
974- LOG_W ("thread suspend: thread disorder, 0x%02x" , RT_SCHED_CTX (thread ).stat );
972+ LOG_W ("thread suspend: thread disorder, 0x%02x" , RT_SCHED_CTX (thread ).stat );
975973 rt_sched_unlock (slvl );
976974 return - RT_ERROR ;
977975 }
976+
977+ if (stat == RT_THREAD_RUNNING )
978+ {
979+ RT_ASSERT (thread == rt_thread_self ());
980+ }
978981
979982#ifdef RT_USING_SMART
980983 if (thread -> lwp )
0 commit comments