comparison packages/kernel/current/src/sched/mlqueue.cxx @ 128:0c2b7be0d798 ecos-sw-2000-10-12

Merge from eCos master repository on 2000-10-12-08:46:24-BST
author jlarmour
date Thu, 12 Oct 2000 20:31:43 +0000
parents 0ec04793409a
children 8f2f7615e727
comparison
equal deleted inserted replaced
127:67f0ef5f8ee9 128:0c2b7be0d798
274 #endif 274 #endif
275 275
276 CYG_ASSERT( sched_lock > 0 , "Timeslice called with zero sched_lock"); 276 CYG_ASSERT( sched_lock > 0 , "Timeslice called with zero sched_lock");
277 277
278 Cyg_Thread *thread = current_thread; 278 Cyg_Thread *thread = current_thread;
279 Cyg_Scheduler *sched = &Cyg_Scheduler::scheduler; 279
280 280 // Only try to rotate the run queue if the current thread is running.
281 CYG_ASSERTCLASS( thread, "Bad current thread"); 281 // Otherwise we are going to reschedule anyway.
282 CYG_ASSERTCLASS( sched, "Bad scheduler"); 282 if( thread->get_state() == Cyg_Thread::RUNNING )
283 283 {
284 cyg_priority pri = thread->priority; 284 Cyg_Scheduler *sched = &Cyg_Scheduler::scheduler;
285 Cyg_SchedulerThreadQueue_Implementation *queue = &sched->run_queue[pri]; 285
286 286 CYG_ASSERTCLASS( thread, "Bad current thread");
287 queue->rotate(); 287 CYG_ASSERTCLASS( sched, "Bad scheduler");
288 288
289 if( queue->highpri() != thread ) 289 cyg_priority pri = thread->priority;
290 sched->need_reschedule = true; 290 Cyg_SchedulerThreadQueue_Implementation *queue = &sched->run_queue[pri];
291 291
292 timeslice_count = CYGNUM_KERNEL_SCHED_TIMESLICE_TICKS; 292 queue->rotate();
293
294 if( queue->highpri() != thread )
295 sched->need_reschedule = true;
296
297 timeslice_count = CYGNUM_KERNEL_SCHED_TIMESLICE_TICKS;
298 }
293 } 299 }
294 300
295 301
296 CYG_ASSERT( queue_map & (1<<CYG_THREAD_MIN_PRIORITY), "Idle thread vanished!!!"); 302 CYG_ASSERT( queue_map & (1<<CYG_THREAD_MIN_PRIORITY), "Idle thread vanished!!!");
297 CYG_ASSERT( !run_queue[CYG_THREAD_MIN_PRIORITY].empty(), "Idle thread vanished!!!"); 303 CYG_ASSERT( !run_queue[CYG_THREAD_MIN_PRIORITY].empty(), "Idle thread vanished!!!");
654 660
655 void 661 void
656 Cyg_ThreadQueue_Implementation::rotate(void) 662 Cyg_ThreadQueue_Implementation::rotate(void)
657 { 663 {
658 CYG_REPORT_FUNCTION(); 664 CYG_REPORT_FUNCTION();
659 665
666 CYG_ASSERT(queue != 0, "Rotating an empty queue");
667
660 queue = queue->next; 668 queue = queue->next;
661 669
662 CYG_REPORT_RETURN(); 670 CYG_REPORT_RETURN();
663 } 671 }
664 672