This is the mail archive of the
ecos-discuss@sources.redhat.com
mailing list for the eCos project.
Thread scheduling
- From: Giovanni Perbellini <perbelli at sci dot univr dot it>
- To: <ecos-discuss at sources dot redhat dot com>
- Date: Fri, 27 Feb 2004 11:11:36 +0100 (MET)
- Subject: [ECOS] Thread scheduling
Hi all,
I don't understand the behavoir of the scheduler.
I have a simple application running two threads with euqal priority
(priority = 12).
When the execution starts the ISR function is executed and then the DSR
function is called.The DSR function executes the tick method to calculate the tick SW and
finally the timeslice function is executed to assign a time slot to a
thread (let's suppose to have a single cpu with the threads timeslice
disabled...unique timeslice associates to 1 cpu).
The timeslice calls timeslice_cpu function that checks if the current
thread is running, then tries to rotate the run queue and finally the
need_reschule flag is set.
if( thread->get_state() == Cyg_Thread::RUNNING )
{
Cyg_Scheduler *sched = &Cyg_Scheduler::scheduler;
CYG_INSTRUMENT_MLQ( TIMESLICE, thread, 0);
CYG_ASSERTCLASS( thread, "Bad current thread");
CYG_ASSERTCLASS( sched, "Bad scheduler");
cyg_priority pri = thread->priority;
Cyg_RunQueue *queue = &sched->run_queue[pri];
#ifdef CYGPKG_KERNEL_SMP_SUPPORT
// In SMP systems we set the head of the queue to point to
// the thread immediately after the current
// thread. schedule() will then pick that thread, or one
// after it to run next.
queue->to_head( thread->get_next() );
#else
queue->rotate();
#endif
if( queue->get_head() != thread )
sched->set_need_reschedule();
timeslice_count[cpu_this] = CYGNUM_KERNEL_SCHED_TIMESLICE_TICKS;
}
What happens when this function is finished?
Is the schedule method called?
I guess that the scheduler executes the same prevoius thread even if it
should the context switch. Why?
Best regards
Thanks
Giovanni Perbellini
--
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss