mirror of
https://github.com/RT-Thread/rt-thread.git
synced 2026-10-07 00:59:00 +08:00
添加idle回收资源的修改
This commit is contained in:
+5
-1
@@ -168,7 +168,6 @@ void rt_thread_idle_init(void);
|
||||
rt_err_t rt_thread_idle_sethook(void (*hook)(void));
|
||||
rt_err_t rt_thread_idle_delhook(void (*hook)(void));
|
||||
#endif
|
||||
void rt_thread_idle_excute(void);
|
||||
rt_thread_t rt_thread_idle_gethandler(void);
|
||||
|
||||
/*
|
||||
@@ -187,6 +186,7 @@ rt_uint16_t rt_critical_level(void);
|
||||
|
||||
#ifdef RT_USING_HOOK
|
||||
void rt_scheduler_sethook(void (*hook)(rt_thread_t from, rt_thread_t to));
|
||||
void rt_scheduler_switchto_sethook(void (*hook)(struct rt_thread *tid));
|
||||
#endif
|
||||
|
||||
#ifdef RT_USING_SMP
|
||||
@@ -396,6 +396,10 @@ rt_err_t rt_mq_recv(rt_mq_t mq,
|
||||
rt_err_t rt_mq_control(rt_mq_t mq, int cmd, void *arg);
|
||||
#endif
|
||||
|
||||
/* defunct */
|
||||
void rt_thread_defunct_enqueue(rt_thread_t thread);
|
||||
rt_thread_t rt_thread_defunct_dequeue(void);
|
||||
|
||||
/*
|
||||
* spinlock
|
||||
*/
|
||||
|
||||
@@ -98,6 +98,11 @@ config IDLE_THREAD_STACK_SIZE
|
||||
int "The stack size of idle thread"
|
||||
default 256
|
||||
|
||||
config SYSTEM_THREAD_STACK_SIZE
|
||||
int "The stack size of system thread (for defunct etc.)"
|
||||
depends on RT_USING_SMP
|
||||
default IDLE_THREAD_STACK_SIZE
|
||||
|
||||
config RT_USING_TIMER_SOFT
|
||||
bool "Enable software timer with a timer thread"
|
||||
default y
|
||||
|
||||
+133
-21
File diff suppressed because it is too large
Load Diff
@@ -47,8 +47,6 @@ struct rt_thread *rt_current_thread = RT_NULL;
|
||||
rt_uint8_t rt_current_priority;
|
||||
#endif /* RT_USING_SMP */
|
||||
|
||||
rt_list_t rt_thread_defunct;
|
||||
|
||||
#ifdef RT_USING_HOOK
|
||||
static void (*rt_scheduler_hook)(struct rt_thread *from, struct rt_thread *to);
|
||||
|
||||
@@ -224,9 +222,6 @@ void rt_system_scheduler_init(void)
|
||||
/* initialize ready table */
|
||||
rt_memset(rt_thread_ready_table, 0, sizeof(rt_thread_ready_table));
|
||||
#endif /* RT_THREAD_PRIORITY_MAX > 32 */
|
||||
|
||||
/* initialize thread defunct */
|
||||
rt_list_init(&rt_thread_defunct);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+25
-15
@@ -32,8 +32,6 @@
|
||||
#include <rthw.h>
|
||||
#include <rtthread.h>
|
||||
|
||||
extern rt_list_t rt_thread_defunct;
|
||||
|
||||
#ifdef RT_USING_HOOK
|
||||
static void (*rt_thread_suspend_hook)(rt_thread_t thread);
|
||||
static void (*rt_thread_resume_hook) (rt_thread_t thread);
|
||||
@@ -131,7 +129,7 @@ static void _rt_thread_exit(void)
|
||||
else
|
||||
{
|
||||
/* insert to defunct thread list */
|
||||
rt_list_insert_after(&rt_thread_defunct, &(thread->tlist));
|
||||
rt_thread_defunct_enqueue(thread);
|
||||
}
|
||||
|
||||
/* switch to next task */
|
||||
@@ -379,17 +377,22 @@ rt_err_t rt_thread_detach(rt_thread_t thread)
|
||||
/* release thread timer */
|
||||
rt_timer_detach(&(thread->thread_timer));
|
||||
|
||||
/* disable interrupt */
|
||||
lock = rt_hw_interrupt_disable();
|
||||
|
||||
/* change stat */
|
||||
thread->stat = RT_THREAD_CLOSE;
|
||||
|
||||
/* detach thread object */
|
||||
rt_object_detach((rt_object_t)thread);
|
||||
|
||||
/* enable interrupt */
|
||||
rt_hw_interrupt_enable(lock);
|
||||
if (rt_object_is_systemobject((rt_object_t)thread) == RT_TRUE)
|
||||
{
|
||||
rt_object_detach((rt_object_t)thread);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* disable interrupt */
|
||||
lock = rt_hw_interrupt_disable();
|
||||
/* insert to defunct thread list */
|
||||
rt_thread_defunct_enqueue(thread);
|
||||
/* enable interrupt */
|
||||
rt_hw_interrupt_enable(lock);
|
||||
}
|
||||
|
||||
return RT_EOK;
|
||||
}
|
||||
@@ -484,7 +487,7 @@ rt_err_t rt_thread_delete(rt_thread_t thread)
|
||||
thread->stat = RT_THREAD_CLOSE;
|
||||
|
||||
/* insert to defunct thread list */
|
||||
rt_list_insert_after(&rt_thread_defunct, &(thread->tlist));
|
||||
rt_thread_defunct_enqueue(thread);
|
||||
|
||||
/* enable interrupt */
|
||||
rt_hw_interrupt_enable(lock);
|
||||
@@ -847,12 +850,12 @@ rt_err_t rt_thread_resume(rt_thread_t thread)
|
||||
|
||||
rt_timer_stop(&thread->thread_timer);
|
||||
|
||||
/* enable interrupt */
|
||||
rt_hw_interrupt_enable(temp);
|
||||
|
||||
/* insert to schedule ready list */
|
||||
rt_schedule_insert_thread(thread);
|
||||
|
||||
/* enable interrupt */
|
||||
rt_hw_interrupt_enable(temp);
|
||||
|
||||
RT_OBJECT_HOOK_CALL(rt_thread_resume_hook, (thread));
|
||||
return RT_EOK;
|
||||
}
|
||||
@@ -867,6 +870,7 @@ RTM_EXPORT(rt_thread_resume);
|
||||
void rt_thread_timeout(void *parameter)
|
||||
{
|
||||
struct rt_thread *thread;
|
||||
register rt_base_t temp;
|
||||
|
||||
thread = (struct rt_thread *)parameter;
|
||||
|
||||
@@ -875,6 +879,9 @@ void rt_thread_timeout(void *parameter)
|
||||
RT_ASSERT((thread->stat & RT_THREAD_STAT_MASK) == RT_THREAD_SUSPEND);
|
||||
RT_ASSERT(rt_object_get_type((rt_object_t)thread) == RT_Object_Class_Thread);
|
||||
|
||||
/* disable interrupt */
|
||||
temp = rt_hw_interrupt_disable();
|
||||
|
||||
/* set error number */
|
||||
thread->error = -RT_ETIMEOUT;
|
||||
|
||||
@@ -884,6 +891,9 @@ void rt_thread_timeout(void *parameter)
|
||||
/* insert to schedule ready list */
|
||||
rt_schedule_insert_thread(thread);
|
||||
|
||||
/* enable interrupt */
|
||||
rt_hw_interrupt_enable(temp);
|
||||
|
||||
/* do schedule */
|
||||
rt_schedule();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user