/[rtmk]/rtmk/thread.c
ViewVC logotype

Diff of /rtmk/thread.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.9 by jrydberg, Thu Jan 3 21:38:14 2002 UTC revision 1.10 by jrydberg, Mon Jan 7 01:16:21 2002 UTC
# Line 15  You should have received a copy of the G Line 15  You should have received a copy of the G
15  along with this program; if not, write to the Free Software  along with this program; if not, write to the Free Software
16  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
17    
 /* remaining to do is to implement some form of round robin scheduling  
    for realtime threads.  */  
   
18  #include <rtmk/kern-return.h>  #include <rtmk/kern-return.h>
19    
20  #include "tm.h"  #include "tm.h"
# Line 198  thread_continue (struct thread *old_thre Line 195  thread_continue (struct thread *old_thre
195       There might not be an old thread, if we are       There might not be an old thread, if we are
196       the first thread to run on this processor.  */       the first thread to run on this processor.  */
197    
198    #if 0
199    if (old_thread != 0)    if (old_thread != 0)
200      thread_dispatch (old_thread);      thread_dispatch (old_thread);
   
 #if 0  
   trace_printf ("new stack ?");  
201  #endif  #endif
202    
203    SPL0 ();    SPL0 ();
# Line 219  static bool Line 214  static bool
214  thread_invoke (struct thread *old_thread, void (*continuation) (void),  thread_invoke (struct thread *old_thread, void (*continuation) (void),
215                 struct thread *new_thread)                 struct thread *new_thread)
216  {  {
217    
218    /* Check if we're invoking the current thread.  */    /* Check if we're invoking the current thread.  */
219    if (new_thread == old_thread)    if (new_thread == old_thread)
220      {      {
# Line 231  thread_invoke (struct thread *old_thread Line 227  thread_invoke (struct thread *old_thread
227        return true;        return true;
228      }      }
229    
230    #if 0
231      trace_printf ("cpu #%d old %p new %p cont %p",
232                    CPU_CURRENT (), old_thread, new_thread, continuation);
233    #endif
234    
235    /* Check for stack handoff.  */    /* Check for stack handoff.  */
236    
237    if (continuation != 0)    if (continuation != 0)
# Line 268  thread_invoke (struct thread *old_thread Line 269  thread_invoke (struct thread *old_thread
269      {      {
270        if (new_thread->sched_state & THREAD_STATE_SWAPPED)        if (new_thread->sched_state & THREAD_STATE_SWAPPED)
271          {          {
 #if 0  
           trace_printf ("here! %x", new_thread->sched_state);  
 #endif  
   
272            stack_alloc (new_thread, (void (*)()) thread_continue);            stack_alloc (new_thread, (void (*)()) thread_continue);
273            new_thread->sched_state &= ~THREAD_STATE_SWAPPED;            new_thread->sched_state &= ~THREAD_STATE_SWAPPED;
274          }          }
275          
276        switch (old_thread->sched_state & ~THREAD_STATE_SWAPPED)        switch (old_thread->sched_state & ~THREAD_STATE_SWAPPED)
277          {          {
278          case THREAD_STATE_RUN:          case THREAD_STATE_RUN:
# Line 295  thread_invoke (struct thread *old_thread Line 292  thread_invoke (struct thread *old_thread
292        void (*new_continuation) () = new_thread->swap_fn;        void (*new_continuation) () = new_thread->swap_fn;
293    
294        new_thread->swap_fn = (void (*)()) 0;        new_thread->swap_fn = (void (*)()) 0;
295  #if 0  
       trace_printf ("here");  
 #endif  
296        SPL0 ();        SPL0 ();
297        CALL_CONTINUATION (new_continuation);        CALL_CONTINUATION (new_continuation);
298        /* NOTREACHED */        /* NOTREACHED */
# Line 578  thread_will_priority (struct thread *thr Line 573  thread_will_priority (struct thread *thr
573    
574        if (! thread->blocked_lock)        if (! thread->blocked_lock)
575          break;          break;
576        thread = thread->blocked_lock->thread;        thread = thread->blocked_lock->owner;
577      }      }
578    
579    SPLON (spl);    SPLON (spl);
# Line 671  thread_select (struct processor *process Line 666  thread_select (struct processor *process
666      {      {
667        thread = (*sched_policies[i].ops->select_fn) (&sched_policies[i],        thread = (*sched_policies[i].ops->select_fn) (&sched_policies[i],
668                                                      processor);                                                      processor);
 #if 0  
       if (thread)  
         trace_printf ("got thread %p %d", thread,  
                       (int) thread->scratch_area [3]);  
 #endif  
669        if (thread)        if (thread)
670          return thread;          return thread;
671      }      }
# Line 741  thread_setrun (struct thread *thread, bo Line 731  thread_setrun (struct thread *thread, bo
731    
732    assert ((thread->sched_state & THREAD_SCHED_STATE) == THREAD_STATE_RUN);    assert ((thread->sched_state & THREAD_SCHED_STATE) == THREAD_STATE_RUN);
733    
734  #if NCPUS > 1    #if NCPUS > 1
735    /* First check if we can continue to execute on processor that last    /* First check if we can continue to execute on processor that last
736       executed thread.  */       executed thread.  */
737    
# Line 754  thread_setrun (struct thread *thread, bo Line 744  thread_setrun (struct thread *thread, bo
744            processor->state = PROCESSOR_STATE_DISPATCH;            processor->state = PROCESSOR_STATE_DISPATCH;
745    
746            /* ??? send interrupt to processor.  */            /* ??? send interrupt to processor.  */
           return;  
747          }          }
748      }      }
749    
# Line 771  thread_setrun (struct thread *thread, bo Line 760  thread_setrun (struct thread *thread, bo
760            processor->state = PROCESSOR_STATE_DISPATCH;            processor->state = PROCESSOR_STATE_DISPATCH;
761                        
762            /* ??? send interrupt to processor.  */            /* ??? send interrupt to processor.  */
763            return;  
764          }          }
765        else if (processor->state == PROCESSOR_STATE_RUNNING &&        else if (processor->state == PROCESSOR_STATE_RUNNING &&
766                 thread->sched_premul > processor->current_thread->sched_premul)                 thread->sched_premul > processor->current_thread->sched_premul)
767          {          {
768            /* ??? send interrupt to processor.  */            /* ??? send interrupt to processor.  */
769            return;  
770          }          }
771      }      }
772  #endif  #endif

Legend:
Removed from v.1.9  
changed lines
  Added in v.1.10

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26