1 //==========================================================================
5 // Multi-level queue scheduler class implementation
7 //==========================================================================
8 //####ECOSGPLCOPYRIGHTBEGIN####
9 // -------------------------------------------
10 // This file is part of eCos, the Embedded Configurable Operating System.
11 // Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
13 // eCos is free software; you can redistribute it and/or modify it under
14 // the terms of the GNU General Public License as published by the Free
15 // Software Foundation; either version 2 or (at your option) any later version.
17 // eCos is distributed in the hope that it will be useful, but WITHOUT ANY
18 // WARRANTY; without even the implied warranty of MERCHANTABILITY or
19 // FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22 // You should have received a copy of the GNU General Public License along
23 // with eCos; if not, write to the Free Software Foundation, Inc.,
24 // 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
26 // As a special exception, if other files instantiate templates or use macros
27 // or inline functions from this file, or you compile this file and link it
28 // with other works to produce a work based on this file, this file does not
29 // by itself cause the resulting work to be covered by the GNU General Public
30 // License. However the source code for this file must still be made available
31 // in accordance with section (3) of the GNU General Public License.
33 // This exception does not invalidate any other reasons why a work based on
34 // this file might be covered by the GNU General Public License.
36 // Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
37 // at http://sources.redhat.com/ecos/ecos-license/
38 // -------------------------------------------
39 //####ECOSGPLCOPYRIGHTEND####
40 //==========================================================================
41 //#####DESCRIPTIONBEGIN####
44 // Contributors: jlarmour
46 // Purpose: Multilevel queue scheduler class implementation
47 // Description: This file contains the implementations of
48 // Cyg_Scheduler_Implementation and
49 // Cyg_SchedThread_Implementation.
52 //####DESCRIPTIONEND####
54 //==========================================================================
56 #include <pkgconf/kernel.h>
58 #include <cyg/kernel/ktypes.h> // base kernel types
59 #include <cyg/infra/cyg_trac.h> // tracing macros
60 #include <cyg/infra/cyg_ass.h> // assertion macros
62 #include <cyg/kernel/sched.hxx> // our header
64 #include <cyg/hal/hal_arch.h> // Architecture specific definitions
66 #include <cyg/kernel/thread.inl> // thread inlines
67 #include <cyg/kernel/sched.inl> // scheduler inlines
69 #ifdef CYGSEM_KERNEL_SCHED_MLQUEUE
71 //==========================================================================
72 // Cyg_Scheduler_Implementation class static members
74 #ifdef CYGSEM_KERNEL_SCHED_TIMESLICE
76 cyg_ucount32 Cyg_Scheduler_Implementation::timeslice_count[CYGNUM_KERNEL_CPU_MAX];
81 //==========================================================================
82 // Cyg_Scheduler_Implementation class members
84 // -------------------------------------------------------------------------
87 Cyg_Scheduler_Implementation::Cyg_Scheduler_Implementation()
89 CYG_REPORT_FUNCTION();
93 #ifdef CYGPKG_KERNEL_SMP_SUPPORT
97 for( int i = 0; i < CYGNUM_KERNEL_SCHED_PRIORITIES; i++ )
102 for( int i = 0; i < CYGNUM_KERNEL_CPU_MAX; i++ )
104 #ifdef CYGSEM_KERNEL_SCHED_TIMESLICE
105 timeslice_count[i] = CYGNUM_KERNEL_SCHED_TIMESLICE_TICKS;
107 need_reschedule[i] = true;
113 // -------------------------------------------------------------------------
114 // Choose the best thread to run next
117 Cyg_Scheduler_Implementation::schedule(void)
119 CYG_REPORT_FUNCTYPE("returning thread %08x");
121 // The run queue may _never_ be empty, there is always
122 // an idle thread at the lowest priority.
124 CYG_ASSERT( queue_map != 0, "Run queue empty");
125 CYG_ASSERT( queue_map & (1<<CYG_THREAD_MIN_PRIORITY), "Idle thread vanished!!!");
126 CYG_ASSERT( !run_queue[CYG_THREAD_MIN_PRIORITY].empty(), "Idle thread vanished!!!");
128 #ifdef CYGPKG_KERNEL_SMP_SUPPORT
130 Cyg_Thread *current = get_current_thread();
131 register cyg_uint32 index;
133 CYG_ASSERT( current->cpu != CYG_KERNEL_CPU_NONE, "Current thread does not have CPU set!");
135 // If the current thread is still runnable, return it to pending
136 // state so that it can be considered alongside any other threads
138 if( current->get_state() == Cyg_Thread::RUNNING )
140 current->cpu = CYG_KERNEL_CPU_NONE;
141 pending[current->priority]++;
142 pending_map |= (1<<current->priority);
146 // Otherwise, ensure that the thread is no longer marked as
148 current->cpu = CYG_KERNEL_CPU_NONE;
152 HAL_LSBIT_INDEX(index, pending_map);
154 Cyg_RunQueue *queue = &run_queue[index];
156 CYG_ASSERT( !queue->empty(), "Queue for index empty");
157 CYG_ASSERT( pending[index] > 0, "Pending array and map disagree");
159 Cyg_Thread *thread = queue->get_head();
161 // We know there is a runnable thread in this queue, If the thread
162 // we got is not it, scan until we find it. While not constant time,
163 // this search has an upper bound of the number of CPUs in the system.
165 while( thread->cpu != CYG_KERNEL_CPU_NONE )
166 thread = thread->get_next();
168 // Take newly scheduled thread out of pending map
169 thread->cpu = CYG_KERNEL_CPU_THIS();
170 if( --pending[index] == 0 )
171 pending_map &= ~(1<<index);
175 register cyg_uint32 index;
177 HAL_LSBIT_INDEX(index, queue_map);
179 Cyg_RunQueue *queue = &run_queue[index];
181 CYG_ASSERT( !queue->empty(), "Queue for index empty");
183 Cyg_Thread *thread = queue->get_head();
187 CYG_INSTRUMENT_MLQ( SCHEDULE, thread, index);
189 CYG_ASSERT( thread != NULL , "No threads in run queue");
190 CYG_ASSERT( thread->queue == NULL , "Runnable thread on a queue!");
192 CYG_REPORT_RETVAL(thread);
197 // -------------------------------------------------------------------------
200 Cyg_Scheduler_Implementation::add_thread(Cyg_Thread *thread)
202 CYG_REPORT_FUNCTION();
203 CYG_REPORT_FUNCARG1("thread=%08x", thread);
205 cyg_priority pri = thread->priority;
206 Cyg_RunQueue *queue = &run_queue[pri];
208 CYG_INSTRUMENT_MLQ( ADD, thread, pri);
210 CYG_ASSERT((CYG_THREAD_MIN_PRIORITY >= pri)
211 && (CYG_THREAD_MAX_PRIORITY <= pri),
212 "Priority out of range!");
214 CYG_ASSERT( ((queue_map & (1<<pri))!=0) == ((!run_queue[pri].empty())!=0), "Map and queue disagree");
216 // If the thread is on some other queue, remove it
218 if( thread->queue != NULL )
220 thread->queue->remove(thread);
225 // set the map bit and ask for a reschedule if this is a
226 // new highest priority thread.
228 queue_map |= (1<<pri);
231 // else the queue already has an occupant, queue behind him
233 queue->add_tail(thread);
235 // If the new thread is higher priority than any
236 // current thread, request a reschedule.
238 set_need_reschedule(thread);
240 #ifdef CYGPKG_KERNEL_SMP_SUPPORT
242 // If the thread is not currently running, increment the pending
243 // count for the priority, and if necessary set the bit in the
246 if( thread->cpu == CYG_KERNEL_CPU_NONE )
248 if( pending[pri]++ == 0 )
249 pending_map |= (1<<pri);
251 // Otherwise the pending count will be dealt with in schedule().
255 CYG_ASSERT( thread->queue == NULL , "Runnable thread on a queue!");
256 CYG_ASSERT( queue_map != 0, "Run queue empty");
257 CYG_ASSERT( queue_map & (1<<pri), "Queue map bit not set for pri");
258 CYG_ASSERT( !run_queue[pri].empty(), "Queue for pri empty");
259 CYG_ASSERT( ((queue_map & (1<<pri))!=0) == ((!run_queue[pri].empty())!=0), "Map and queue disagree");
260 CYG_ASSERT( queue_map & (1<<CYG_THREAD_MIN_PRIORITY), "Idle thread vanished!!!");
261 CYG_ASSERT( !run_queue[CYG_THREAD_MIN_PRIORITY].empty(), "Idle thread vanished!!!");
266 // -------------------------------------------------------------------------
269 Cyg_Scheduler_Implementation::rem_thread(Cyg_Thread *thread)
271 CYG_REPORT_FUNCTION();
272 CYG_REPORT_FUNCARG1("thread=%08x", thread);
274 CYG_ASSERT( queue_map != 0, "Run queue empty");
276 cyg_priority pri = thread->priority;
277 Cyg_RunQueue *queue = &run_queue[pri];
279 CYG_INSTRUMENT_MLQ( REM, thread, pri);
281 CYG_ASSERT( pri != CYG_THREAD_MIN_PRIORITY, "Idle thread trying to sleep!");
282 CYG_ASSERT( !run_queue[CYG_THREAD_MIN_PRIORITY].empty(), "Idle thread vanished!!!");
284 #ifdef CYGPKG_KERNEL_SMP_SUPPORT
286 if( thread->cpu == CYG_KERNEL_CPU_NONE )
288 // If the thread is not running, then we need to adjust the
289 // pending count array and map if necessary.
291 if( --pending[pri] == 0 )
292 pending_map &= ~(1<<pri);
296 // If the target thread is currently running on a different
297 // CPU, send a reschedule interrupt there to deschedule it.
298 if( thread->cpu != CYG_KERNEL_CPU_THIS() )
299 CYG_KERNEL_CPU_RESCHEDULE_INTERRUPT( thread->cpu, 0 );
301 // If the thread is current running on this CPU, then the pending
302 // count will be dealt with in schedule().
306 CYG_ASSERT( queue_map & (1<<pri), "Queue map bit not set for pri");
307 CYG_ASSERT( !run_queue[pri].empty(), "Queue for pri empty");
309 // remove thread from queue
310 queue->remove(thread);
314 // If this was only thread in
317 queue_map &= ~(1<<pri);
320 CYG_ASSERT( queue_map != 0, "Run queue empty");
321 CYG_ASSERT( queue_map & (1<<CYG_THREAD_MIN_PRIORITY), "Idle thread vanished!!!");
322 CYG_ASSERT( !run_queue[CYG_THREAD_MIN_PRIORITY].empty(), "Idle thread vanished!!!");
323 CYG_ASSERT( ((queue_map & (1<<pri))!=0) == ((!run_queue[pri].empty())!=0), "Map and queue disagree");
328 // -------------------------------------------------------------------------
329 // Set the need_reschedule flag
330 // This function overrides the definition in Cyg_Scheduler_Base and tests
331 // for a reschedule condition based on the priorities of the given thread
332 // and the current thread(s).
334 void Cyg_Scheduler_Implementation::set_need_reschedule(Cyg_Thread *thread)
336 #ifndef CYGPKG_KERNEL_SMP_SUPPORT
338 if( current_thread[0]->priority > thread->priority ||
339 current_thread[0]->get_state() != Cyg_Thread::RUNNING )
340 need_reschedule[0] = true;
344 HAL_SMP_CPU_TYPE cpu_this = CYG_KERNEL_CPU_THIS();
345 HAL_SMP_CPU_TYPE cpu_count = CYG_KERNEL_CPU_COUNT();
347 // Start with current CPU. If we can do the job locally then
348 // that is most efficient. Only go on to other CPUs if that is
351 for(int i = 0; i < cpu_count; i++)
353 HAL_SMP_CPU_TYPE cpu = (i + cpu_this) % cpu_count;
355 // If a CPU is not already marked for rescheduling, and its
356 // current thread is of lower priority than _thread_, then
357 // set its need_reschedule flag.
359 Cyg_Thread *cur = current_thread[cpu];
361 if( (!need_reschedule[cpu]) &&
362 (cur->priority > thread->priority)
365 need_reschedule[cpu] = true;
367 if( cpu != cpu_this )
369 // All processors other than this one need to be sent
370 // a reschedule interrupt.
372 CYG_INSTRUMENT_SMP( RESCHED_SEND, cpu, 0 );
373 CYG_KERNEL_CPU_RESCHEDULE_INTERRUPT( cpu, 0 );
376 // Having notionally rescheduled _thread_ onto the cpu, we
377 // now see if we can reschedule the former current thread of
378 // that CPU onto another.
387 // -------------------------------------------------------------------------
388 // Set up initial idle thread
390 void Cyg_Scheduler_Implementation::set_idle_thread( Cyg_Thread *thread, HAL_SMP_CPU_TYPE cpu )
392 // Make the thread the current thread for this CPU.
394 current_thread[cpu] = thread;
396 // This will insert the thread in the run queues and make it
397 // available to execute.
400 #ifdef CYGPKG_KERNEL_SMP_SUPPORT
404 // In SMP, we need to take this thread out of the pending array
407 cyg_priority pri = thread->priority;
408 if( --pending[pri] == 0 )
409 pending_map &= ~(1<<pri);
414 // -------------------------------------------------------------------------
415 // register thread with scheduler
418 Cyg_Scheduler_Implementation::register_thread(Cyg_Thread *thread)
420 CYG_REPORT_FUNCTION();
421 CYG_REPORT_FUNCARG1("thread=%08x", thread);
422 // No registration necessary in this scheduler
426 // -------------------------------------------------------------------------
430 Cyg_Scheduler_Implementation::deregister_thread(Cyg_Thread *thread)
432 CYG_REPORT_FUNCTION();
433 CYG_REPORT_FUNCARG1("thread=%08x", thread);
434 // No registration necessary in this scheduler
438 // -------------------------------------------------------------------------
439 // Test the given priority for uniqueness
442 Cyg_Scheduler_Implementation::unique( cyg_priority priority)
444 CYG_REPORT_FUNCTYPE("returning %d");
445 CYG_REPORT_FUNCARG1("priority=%d", priority);
446 // Priorities are not unique
447 CYG_REPORT_RETVAL(true);
451 //==========================================================================
452 // Support for timeslicing option
454 #ifdef CYGSEM_KERNEL_SCHED_TIMESLICE
456 // -------------------------------------------------------------------------
459 Cyg_Scheduler_Implementation::timeslice(void)
461 #ifdef CYGDBG_KERNEL_TRACE_TIMESLICE
462 CYG_REPORT_FUNCTION();
465 #ifdef CYGPKG_KERNEL_SMP_SUPPORT
467 HAL_SMP_CPU_TYPE cpu;
468 HAL_SMP_CPU_TYPE cpu_count = CYG_KERNEL_CPU_COUNT();
469 HAL_SMP_CPU_TYPE cpu_this = CYG_KERNEL_CPU_THIS();
471 for( cpu = 0; cpu < cpu_count; cpu++ )
473 if( --timeslice_count[cpu] == 0 )
474 if( cpu == cpu_this )
476 else CYG_KERNEL_CPU_TIMESLICE_INTERRUPT( cpu, 0 );
481 if( --timeslice_count[CYG_KERNEL_CPU_THIS()] == 0 )
486 #ifdef CYGDBG_KERNEL_TRACE_TIMESLICE
491 // -------------------------------------------------------------------------
494 Cyg_Scheduler_Implementation::timeslice_cpu(void)
496 #ifdef CYGDBG_KERNEL_TRACE_TIMESLICE
497 CYG_REPORT_FUNCTION();
500 Cyg_Thread *thread = get_current_thread();
501 HAL_SMP_CPU_TYPE cpu_this = CYG_KERNEL_CPU_THIS();
503 CYG_ASSERT( queue_map != 0, "Run queue empty");
504 CYG_ASSERT( queue_map & (1<<CYG_THREAD_MIN_PRIORITY), "Idle thread vanished!!!");
506 #ifdef CYGSEM_KERNEL_SCHED_TIMESLICE_ENABLE
507 if( thread->timeslice_enabled &&
508 timeslice_count[cpu_this] == 0 )
510 if( timeslice_count[cpu_this] == 0 )
513 CYG_INSTRUMENT_SCHED(TIMESLICE,0,0);
514 #ifdef CYGDBG_KERNEL_TRACE_TIMESLICE
515 CYG_TRACE0( true, "quantum consumed, time to reschedule" );
518 CYG_ASSERT( get_sched_lock() > 0 , "Timeslice called with zero sched_lock");
520 // Only try to rotate the run queue if the current thread is running.
521 // Otherwise we are going to reschedule anyway.
522 if( thread->get_state() == Cyg_Thread::RUNNING )
524 Cyg_Scheduler *sched = &Cyg_Scheduler::scheduler;
526 CYG_INSTRUMENT_MLQ( TIMESLICE, thread, 0);
528 CYG_ASSERTCLASS( thread, "Bad current thread");
529 CYG_ASSERTCLASS( sched, "Bad scheduler");
531 cyg_priority pri = thread->priority;
532 Cyg_RunQueue *queue = &sched->run_queue[pri];
534 #ifdef CYGPKG_KERNEL_SMP_SUPPORT
536 // In SMP systems we set the head of the queue to point to
537 // the thread immediately after the current
538 // thread. schedule() will then pick that thread, or one
539 // after it to run next.
541 queue->to_head( thread->get_next() );
546 if( queue->get_head() != thread )
547 sched->set_need_reschedule();
549 timeslice_count[cpu_this] = CYGNUM_KERNEL_SCHED_TIMESLICE_TICKS;
554 CYG_ASSERT( queue_map & (1<<CYG_THREAD_MIN_PRIORITY), "Idle thread vanished!!!");
555 CYG_ASSERT( !run_queue[CYG_THREAD_MIN_PRIORITY].empty(), "Idle thread vanished!!!");
556 #ifdef CYGDBG_KERNEL_TRACE_TIMESLICE
561 // -------------------------------------------------------------------------
563 __externC void cyg_scheduler_timeslice_cpu(void)
565 Cyg_Scheduler::scheduler.timeslice_cpu();
570 //==========================================================================
571 // Cyg_SchedThread_Implementation class members
573 Cyg_SchedThread_Implementation::Cyg_SchedThread_Implementation
575 CYG_ADDRWORD sched_info
578 CYG_REPORT_FUNCTION();
579 CYG_REPORT_FUNCARG1("sched_info=%08x", sched_info);
581 // Set priority to the supplied value.
582 priority = (cyg_priority)sched_info;
584 #ifdef CYGSEM_KERNEL_SCHED_TIMESLICE_ENABLE
585 // If timeslice_enabled exists, set it true by default
586 timeslice_enabled = true;
588 #ifdef CYGPKG_KERNEL_SMP_SUPPORT
589 cpu = CYG_KERNEL_CPU_NONE;
595 // -------------------------------------------------------------------------
596 // Yield the processor to another thread
599 Cyg_SchedThread_Implementation::yield(void)
601 CYG_REPORT_FUNCTION();
603 // Prevent preemption
604 Cyg_Scheduler::lock();
606 Cyg_Thread *thread = CYG_CLASSFROMBASE(Cyg_Thread,
607 Cyg_SchedThread_Implementation,
610 // Only do this if this thread is running. If it is not, there
613 if( thread->get_state() == Cyg_Thread::RUNNING )
615 // To yield we simply rotate the appropriate
616 // run queue to the next thread and reschedule.
618 CYG_INSTRUMENT_MLQ( YIELD, thread, 0);
620 CYG_ASSERTCLASS( thread, "Bad current thread");
622 Cyg_Scheduler *sched = &Cyg_Scheduler::scheduler;
624 CYG_ASSERTCLASS( sched, "Bad scheduler");
626 cyg_priority pri = thread->priority;
627 Cyg_RunQueue *queue = &sched->run_queue[pri];
629 #ifdef CYGPKG_KERNEL_SMP_SUPPORT
631 // In SMP systems we set the head of the queue to point to
632 // the thread immediately after the current
633 // thread. schedule() will then pick that thread, or one
634 // after it to run next.
636 queue->to_head( thread->get_next() );
641 if( queue->get_head() != thread )
642 sched->set_need_reschedule();
644 #ifdef CYGSEM_KERNEL_SCHED_TIMESLICE
645 // Reset the timeslice counter so that this thread gets a full
647 else Cyg_Scheduler::reset_timeslice_count();
651 // Unlock the scheduler and switch threads
652 #ifdef CYGDBG_USE_ASSERTS
653 // This test keeps the assertions in unlock_inner() happy if
654 // need_reschedule was not set above.
655 if( !Cyg_Scheduler::get_need_reschedule() )
656 Cyg_Scheduler::unlock();
659 Cyg_Scheduler::unlock_reschedule();
665 // -------------------------------------------------------------------------
666 // Rotate the run queue at a specified priority.
667 // (pri is the decider, not this, so the routine is static)
670 Cyg_SchedThread_Implementation::rotate_queue( cyg_priority pri )
672 CYG_REPORT_FUNCTION();
673 CYG_REPORT_FUNCARG1("priority=%d", pri);
675 // Prevent preemption
676 Cyg_Scheduler::lock();
678 Cyg_Scheduler *sched = &Cyg_Scheduler::scheduler;
680 CYG_ASSERTCLASS( sched, "Bad scheduler");
682 Cyg_RunQueue *queue = &sched->run_queue[pri];
684 if ( !queue->empty() ) {
686 sched->set_need_reschedule();
689 // Unlock the scheduler and switch threads
690 Cyg_Scheduler::unlock();
695 // -------------------------------------------------------------------------
696 // Move this thread to the head of its queue
697 // (not necessarily a scheduler queue)
700 Cyg_SchedThread_Implementation::to_queue_head( void )
702 CYG_REPORT_FUNCTION();
704 // Prevent preemption
705 Cyg_Scheduler::lock();
707 Cyg_Thread *thread = CYG_CLASSFROMBASE(Cyg_Thread,
708 Cyg_SchedThread_Implementation,
711 CYG_ASSERTCLASS( thread, "Bad current thread");
713 Cyg_ThreadQueue *q = thread->get_current_queue();
715 q->to_head( thread );
716 else if( thread->in_list() )
718 // If the queue pointer is NULL then it is on a run
719 // queue. Move the thread to the head of it's priority list
720 // and force a reschedule.
722 Cyg_Scheduler *sched = &Cyg_Scheduler::scheduler;
723 sched->run_queue[thread->priority].to_head( thread );
724 sched->set_need_reschedule( thread );
727 // Unlock the scheduler and switch threads
728 Cyg_Scheduler::unlock();
733 //==========================================================================
734 // Cyg_ThreadQueue_Implementation class members
736 // -------------------------------------------------------------------------
739 Cyg_ThreadQueue_Implementation::enqueue(Cyg_Thread *thread)
741 CYG_REPORT_FUNCTION();
742 CYG_REPORT_FUNCARG1("thread=%08x", thread);
744 CYG_INSTRUMENT_MLQ( ENQUEUE, this, thread );
746 #ifdef CYGIMP_KERNEL_SCHED_SORTED_QUEUES
748 // Insert the thread into the queue in priority order.
750 Cyg_Thread *qhead = get_head();
752 if( qhead == NULL ) add_tail( thread );
753 else if( qhead == qhead->get_next() )
755 // There is currently only one thread in the queue, join it
756 // and adjust the queue pointer to point to the highest
757 // priority of the two. If they are the same priority,
758 // leave the pointer pointing to the oldest.
760 qhead->insert( thread );
762 if( thread->priority < qhead->priority )
767 // There is more than one thread in the queue. First check
768 // whether we are of higher priority than the head and if
769 // so just jump in at the front. Also check whether we are
770 // lower priority than the tail and jump onto the end.
771 // Otherwise we really have to search the queue to find
774 if( thread->priority < qhead->priority )
776 qhead->insert( thread );
779 else if( thread->priority > get_tail()->priority )
781 // We are lower priority than any thread in the queue,
788 // Search the queue. We do this backwards so that we
789 // always add new threads after any that have the same
792 // Because of the previous tests we know that this
793 // search will terminate before we hit the head of the
794 // queue, hence we do not need to check for that
797 Cyg_Thread *qtmp = get_tail();
799 // Scan the queue until we find a higher or equal
802 while( qtmp->priority > thread->priority )
803 qtmp = qtmp->get_prev();
805 // Append ourself after the node pointed to by qtmp.
807 qtmp->append( thread );
811 // Just add the thread to the tail of the list
815 thread->queue = CYG_CLASSFROMBASE(Cyg_ThreadQueue,
816 Cyg_ThreadQueue_Implementation,
821 // -------------------------------------------------------------------------
824 Cyg_ThreadQueue_Implementation::dequeue(void)
826 CYG_REPORT_FUNCTYPE("returning thread %08x");
828 Cyg_Thread *thread = rem_head();
830 CYG_INSTRUMENT_MLQ( DEQUEUE, this, thread );
833 thread->queue = NULL;
835 CYG_REPORT_RETVAL(thread);
839 // -------------------------------------------------------------------------
842 Cyg_ThreadQueue_Implementation::remove( Cyg_Thread *thread )
844 CYG_REPORT_FUNCTION();
845 CYG_REPORT_FUNCARG1("thread=%08x", thread);
847 CYG_INSTRUMENT_MLQ( REMOVE, this, thread );
849 thread->queue = NULL;
851 Cyg_CList_T<Cyg_Thread>::remove( thread );
856 // -------------------------------------------------------------------------
859 Cyg_ThreadQueue_Implementation::highpri(void)
861 CYG_REPORT_FUNCTYPE("returning thread %08x");
862 CYG_REPORT_RETVAL(get_head());
866 // -------------------------------------------------------------------------
869 Cyg_ThreadQueue_Implementation::set_thread_queue(Cyg_Thread *thread,
870 Cyg_ThreadQueue *tq )
876 // -------------------------------------------------------------------------
880 // -------------------------------------------------------------------------
881 // EOF sched/mlqueue.cxx