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

Diff of /rtmk/processor.c

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

revision 1.5 by jrydberg, Mon Jan 7 02:25:24 2002 UTC revision 1.6 by jrydberg, Fri Jan 11 22:24:11 2002 UTC
# Line 65  processor_init (void) Line 65  processor_init (void)
65    
66    /* The bootstrap processor is always running (at start).  */    /* The bootstrap processor is always running (at start).  */
67    PROCESSOR_CURRENT()->state = PROCESSOR_STATE_RUNNING;    PROCESSOR_CURRENT()->state = PROCESSOR_STATE_RUNNING;
68      PROCESSOR_CURRENT()->cpu_id = CPU_CURRENT ();
69    master_cpu = CPU_CURRENT ();    master_cpu = CPU_CURRENT ();
70  }  }
71    
# Line 112  processor_init_idle_threads (void) Line 113  processor_init_idle_threads (void)
113    
114        thread->sched_state |= THREAD_STATE_IDLE;        thread->sched_state |= THREAD_STATE_IDLE;
115        thread_set_priority (thread, THREAD_POLICY_TIMESHARE, 0);        thread_set_priority (thread, THREAD_POLICY_TIMESHARE, 0);
116          trace_printf ("idle thread prio %d", thread->sched_premul);
117        thread_start (thread, idle_thread_fn, processor);        thread_start (thread, idle_thread_fn, processor);
118      }      }
119  }  }
# Line 151  processor_send_dispatch_ipi (struct proc Line 153  processor_send_dispatch_ipi (struct proc
153    if (processor == PROCESSOR_CURRENT ())    if (processor == PROCESSOR_CURRENT ())
154      return;      return;
155    
156    #if 1
157      trace_printf ("cpu %d sending dispatch ipi to cpu %d for thread %p",
158                    CPU_CURRENT (), processor->cpu_id, thread);
159    #endif
160    
161    spl = SPLOFF ();    spl = SPLOFF ();
162    msg = get_free_ipi_msg ();    msg = get_free_ipi_msg ();
163        
# Line 165  processor_send_dispatch_ipi (struct proc Line 172  processor_send_dispatch_ipi (struct proc
172    SPLON (spl);    SPLON (spl);
173  }  }
174    
175    /* Terminate THREAD running on PROCESSOR.  */
176    
177    void
178    processor_send_terminate_ipi (struct processor *processor,
179                                  struct thread *thread)
180    {
181      struct ipi_msg *msg;
182      SPL_T spl;
183    
184      if (processor == PROCESSOR_CURRENT ())
185        return;
186    
187      spl = SPLOFF ();
188      msg = get_free_ipi_msg ();
189      
190      msg->ipi_type = PROCESSOR_IPI_TERMINATE;
191      msg->common.terminate.dead_thread = thread;
192    
193      spin_lock (&processor->lock);
194      enqueue_tail (&processor->ipi_msg_list, &msg->link);
195      spin_unlock (&processor->lock);
196    
197      SEND_IPI (processor->cpu_id);
198      SPLON (spl);
199    }
200    
201  /* Interprocess interrupt handler. ??? called with interrupts disabled?  */  /* Interprocess interrupt handler. ??? called with interrupts disabled?  */
202    
203  void  void
204  processor_ipi_handler (void)  processor_ipi_handler (void)
205  {  {
206    struct processor *this_processor = PROCESSOR_CURRENT ();    struct processor *this_processor = PROCESSOR_CURRENT ();
207      bool halt_p = false, terminate_p = false;
208    struct ipi_msg *msg;    struct ipi_msg *msg;
   bool halt_p = false;  
209    
210    /* Loop through all available messages in this processors msg queue.  */    /* Loop through all available messages in this processors msg queue.  */
211    
# Line 183  processor_ipi_handler (void) Line 216  processor_ipi_handler (void)
216        /* Get first message from queue.  */        /* Get first message from queue.  */
217    
218        msg = (struct ipi_msg *) dequeue_head (&this_processor->ipi_msg_list);        msg = (struct ipi_msg *) dequeue_head (&this_processor->ipi_msg_list);
219          trace_printf ("cpu #%d got ipi msg %d",
220                        CPU_CURRENT (), msg->ipi_type);
221        switch (msg->ipi_type)        switch (msg->ipi_type)
222          {          {
223          case PROCESSOR_IPI_HALT:          case PROCESSOR_IPI_HALT:
# Line 195  processor_ipi_handler (void) Line 230  processor_ipi_handler (void)
230            spin_lock (&this_processor->lock);            spin_lock (&this_processor->lock);
231            break;            break;
232    
233            case PROCESSOR_IPI_TERMINATE:
234              /* Check so that we are still running the thread that we
235                 should terminate.  */
236    
237              if (THREAD_CURRENT () != msg->common.terminate.dead_thread)
238                panic ("??? have switched beyond thread!");
239    
240              terminate_p = true;
241              break;
242    
243          case PROCESSOR_IPI_FLUSH_TLB:          case PROCESSOR_IPI_FLUSH_TLB:
244            break;            break;
245    
# Line 214  processor_ipi_handler (void) Line 259  processor_ipi_handler (void)
259        for (;;)        for (;;)
260          ;          ;
261      }      }
262    
263      /* If we should terminate the current running thread, we do that after
264         we have processed all IPI messages.  */
265    
266      if (terminate_p)
267        thread_zombify_running (THREAD_CURRENT ());
268  }  }

Legend:
Removed from v.1.5  
changed lines
  Added in v.1.6

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