support maximal priority level is 8.
git-svn-id: https://rt-thread.googlecode.com/svn/trunk@568 bbd45198-f89e-11dd-88c7-29a3b14d5316
This commit is contained in:
parent
cb92e84504
commit
f0d78afbf2
|
@ -148,16 +148,19 @@ void rt_system_scheduler_init(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @ingroup SystemInit
|
||||||
* This function will startup scheduler. It will select one thread
|
* This function will startup scheduler. It will select one thread
|
||||||
* with the highest priority level, then switch to it.
|
* with the highest priority level, then switch to it.
|
||||||
*/
|
*/
|
||||||
void rt_system_scheduler_start()
|
void rt_system_scheduler_start()
|
||||||
{
|
{
|
||||||
register rt_uint8_t number;
|
register struct rt_thread *to_thread;
|
||||||
register rt_uint8_t highest_ready_priority;
|
register rt_ubase_t highest_ready_priority;
|
||||||
|
|
||||||
struct rt_thread *to_thread;
|
|
||||||
|
|
||||||
|
#if RT_THREAD_PRIORITY_MAX == 8
|
||||||
|
highest_ready_priority = rt_lowest_bitmap[rt_thread_ready_priority_group];
|
||||||
|
#else
|
||||||
|
register rt_ubase_t number;
|
||||||
/* find out the highest priority task */
|
/* find out the highest priority task */
|
||||||
if (rt_thread_ready_priority_group & 0xff)
|
if (rt_thread_ready_priority_group & 0xff)
|
||||||
{
|
{
|
||||||
|
@ -180,6 +183,7 @@ void rt_system_scheduler_start()
|
||||||
highest_ready_priority = (number << 3) + rt_lowest_bitmap[rt_thread_ready_table[number]];
|
highest_ready_priority = (number << 3) + rt_lowest_bitmap[rt_thread_ready_table[number]];
|
||||||
#else
|
#else
|
||||||
highest_ready_priority = number;
|
highest_ready_priority = number;
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* get switch to thread */
|
/* get switch to thread */
|
||||||
|
@ -205,10 +209,7 @@ void rt_system_scheduler_start()
|
||||||
*/
|
*/
|
||||||
void rt_schedule()
|
void rt_schedule()
|
||||||
{
|
{
|
||||||
register rt_uint8_t number;
|
rt_base_t level;
|
||||||
register rt_base_t level;
|
|
||||||
register rt_uint8_t highest_ready_priority;
|
|
||||||
|
|
||||||
struct rt_thread *to_thread;
|
struct rt_thread *to_thread;
|
||||||
struct rt_thread *from_thread;
|
struct rt_thread *from_thread;
|
||||||
|
|
||||||
|
@ -218,6 +219,12 @@ void rt_schedule()
|
||||||
/* check the scheduler is enabled or not */
|
/* check the scheduler is enabled or not */
|
||||||
if (rt_scheduler_lock_nest == 0)
|
if (rt_scheduler_lock_nest == 0)
|
||||||
{
|
{
|
||||||
|
register rt_ubase_t highest_ready_priority;
|
||||||
|
|
||||||
|
#if RT_THREAD_PRIORITY_MAX == 8
|
||||||
|
highest_ready_priority = rt_lowest_bitmap[rt_thread_ready_priority_group];
|
||||||
|
#else
|
||||||
|
register rt_ubase_t number;
|
||||||
/* find out the highest priority task */
|
/* find out the highest priority task */
|
||||||
if (rt_thread_ready_priority_group & 0xff)
|
if (rt_thread_ready_priority_group & 0xff)
|
||||||
{
|
{
|
||||||
|
@ -240,6 +247,7 @@ void rt_schedule()
|
||||||
highest_ready_priority = (number << 3) + rt_lowest_bitmap[rt_thread_ready_table[number]];
|
highest_ready_priority = (number << 3) + rt_lowest_bitmap[rt_thread_ready_table[number]];
|
||||||
#else
|
#else
|
||||||
highest_ready_priority = number;
|
highest_ready_priority = number;
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
/* get switch to thread */
|
/* get switch to thread */
|
||||||
to_thread = rt_list_entry(rt_thread_priority_table[highest_ready_priority].next,
|
to_thread = rt_list_entry(rt_thread_priority_table[highest_ready_priority].next,
|
||||||
|
@ -309,7 +317,7 @@ void rt_schedule_insert_thread(struct rt_thread* thread)
|
||||||
|
|
||||||
/* set priority mask */
|
/* set priority mask */
|
||||||
#ifdef SCHEDULER_DEBUG
|
#ifdef SCHEDULER_DEBUG
|
||||||
#if RT_THREAD_PRIORITY_MAX == 32
|
#if RT_THREAD_PRIORITY_MAX <= 32
|
||||||
rt_kprintf("insert thread, the priority: %d\n", thread->current_priority);
|
rt_kprintf("insert thread, the priority: %d\n", thread->current_priority);
|
||||||
#else
|
#else
|
||||||
rt_kprintf("insert thread, the priority: %d 0x%x %d\n", thread->number, thread->number_mask, thread->high_mask);
|
rt_kprintf("insert thread, the priority: %d 0x%x %d\n", thread->number, thread->number_mask, thread->high_mask);
|
||||||
|
@ -342,7 +350,7 @@ void rt_schedule_remove_thread(struct rt_thread* thread)
|
||||||
temp = rt_hw_interrupt_disable();
|
temp = rt_hw_interrupt_disable();
|
||||||
|
|
||||||
#ifdef SCHEDULER_DEBUG
|
#ifdef SCHEDULER_DEBUG
|
||||||
#if RT_THREAD_PRIORITY_MAX == 32
|
#if RT_THREAD_PRIORITY_MAX <= 32
|
||||||
rt_kprintf("remove thread, the priority: %d\n", thread->current_priority);
|
rt_kprintf("remove thread, the priority: %d\n", thread->current_priority);
|
||||||
#else
|
#else
|
||||||
rt_kprintf("remove thread, the priority: %d 0x%x %d\n", thread->number,
|
rt_kprintf("remove thread, the priority: %d 0x%x %d\n", thread->number,
|
||||||
|
|
Loading…
Reference in New Issue