summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorbernard.xiong <[email protected]>2010-03-31 23:21:02 +0000
committerbernard.xiong <[email protected]>2010-03-31 23:21:02 +0000
commitf0d78afbf21a4c510b53f35adcdf4f8e99e9ed28 (patch)
tree5e64ae8710c4c8241d19ac6fc20b4003bb6be9b2 /src
parentcb92e8450460667a2bf8d7fb7e3716aad1e9936e (diff)
support maximal priority level is 8.
git-svn-id: https://rt-thread.googlecode.com/svn/trunk@568 bbd45198-f89e-11dd-88c7-29a3b14d5316
Diffstat (limited to 'src')
-rw-r--r--src/scheduler.c28
1 files changed, 18 insertions, 10 deletions
diff --git a/src/scheduler.c b/src/scheduler.c
index 6c214d4cd2..c570b3dbbc 100644
--- a/src/scheduler.c
+++ b/src/scheduler.c
@@ -148,16 +148,19 @@ void rt_system_scheduler_init(void)
}
/**
+ * @ingroup SystemInit
* This function will startup scheduler. It will select one thread
* with the highest priority level, then switch to it.
*/
void rt_system_scheduler_start()
{
- register rt_uint8_t number;
- register rt_uint8_t highest_ready_priority;
-
- struct rt_thread *to_thread;
+ register struct rt_thread *to_thread;
+ 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 */
if (rt_thread_ready_priority_group & 0xff)
{
@@ -181,6 +184,7 @@ void rt_system_scheduler_start()
#else
highest_ready_priority = number;
#endif
+#endif
/* get switch to thread */
to_thread = rt_list_entry(rt_thread_priority_table[highest_ready_priority].next,
@@ -205,10 +209,7 @@ void rt_system_scheduler_start()
*/
void rt_schedule()
{
- register rt_uint8_t number;
- register rt_base_t level;
- register rt_uint8_t highest_ready_priority;
-
+ rt_base_t level;
struct rt_thread *to_thread;
struct rt_thread *from_thread;
@@ -218,6 +219,12 @@ void rt_schedule()
/* check the scheduler is enabled or not */
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 */
if (rt_thread_ready_priority_group & 0xff)
{
@@ -241,6 +248,7 @@ void rt_schedule()
#else
highest_ready_priority = number;
#endif
+#endif
/* get switch to thread */
to_thread = rt_list_entry(rt_thread_priority_table[highest_ready_priority].next,
struct rt_thread, tlist);
@@ -309,7 +317,7 @@ void rt_schedule_insert_thread(struct rt_thread* thread)
/* set priority mask */
#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);
#else
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();
#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);
#else
rt_kprintf("remove thread, the priority: %d 0x%x %d\n", thread->number,