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

Diff of /rtmk/timer.c

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

revision 1.6 by jrydberg, Fri Jan 11 22:24:11 2002 UTC revision 1.7 by jrydberg, Thu Feb 21 20:14:42 2002 UTC
# Line 1  Line 1 
1  /* Timers.  /* Timers.
2     Copyright 1999, 2000, 2001 Johan Rydberg, jrydberg@opencores.org.     Copyright 1999, 2000, 2001, 2002 Johan Rydberg, jrydberg@rtmk.org.
3    
4  This program is free software; you can redistribute it and/or modify  This program is free software; you can redistribute it and/or modify
5  it under the terms of the GNU General Public License as published by  it under the terms of the GNU General Public License as published by
# Line 23  Foundation, Inc., 59 Temple Place - Suit Line 23  Foundation, Inc., 59 Temple Place - Suit
23  #include "trace.h"  #include "trace.h"
24  #include "queue.h"  #include "queue.h"
25  #include "vm-slab.h"  #include "vm-slab.h"
26    #include "host.h"
27    
28  struct callout_entry  struct callout_entry
29  {  {
# Line 137  timeout (int millisecs, void (*timeout_f Line 138  timeout (int millisecs, void (*timeout_f
138    return (int) entry;    return (int) entry;
139  }  }
140    
141    /* Cancel a previous call to timeout (MS, FN, ARG).  FN and ARG
142       must match an entry in the callout list.  */
143    
144    void
145    untimeout (void (*fn) (void *arg), void *arg)
146    {
147      struct callout_entry *search_entry;
148      SPL_T spl;
149    
150      spl = SPLOFF ();
151      spin_lock (&callout_list_lock);
152    
153      queue_iterate (&callout_list, search_entry, struct callout_entry *, link)
154        {
155          if (search_entry->timeout_fn == fn && search_entry->timeout_arg == arg)
156            {
157              remque (& search_entry->link);
158              spin_unlock (&callout_list_lock);
159              SPLON (spl);
160    
161              kmem_cache_free (callout_cache, search_entry);
162              return;
163            }
164        }
165    
166      spin_unlock (&callout_list_lock);
167      SPLON (spl);
168    }
169    
170    
171  void  void
172  callout_init (void)  callout_init (void)
173  {  {
# Line 185  timer_interrupt (bool usermode_p) Line 216  timer_interrupt (bool usermode_p)
216    struct thread *thread = THREAD_CURRENT ();    struct thread *thread = THREAD_CURRENT ();
217    struct callout_entry *entry;      struct callout_entry *entry;  
218    bool preempt_p;    bool preempt_p;
219      int cpu;
220    
221  #define CLOCK_RESOLUTION  (1000000000 / HZ)  #define CLOCK_RESOLUTION  (1000000000 / HZ)
222    
223    usermode_p ? timer_bump (&THREAD_CURRENT ()->timer_user, CLOCK_RESOLUTION)    usermode_p ? timer_bump (&THREAD_CURRENT ()->timer_user, CLOCK_RESOLUTION)
224               : timer_bump (&THREAD_CURRENT ()->timer_system, CLOCK_RESOLUTION);               : timer_bump (&THREAD_CURRENT ()->timer_system, CLOCK_RESOLUTION);
225    
226      /* Collect processor information; wether it's an idle tick,
227         a user or a system tick.  ??? can this be optimized?  */
228      cpu = CPU_CURRENT ();
229      if (usermode_p)
230        host_info_processor [cpu].cpu_ticks [PROCESSOR_INFO_STATE_USER]++;
231      else if (thread->sched_state & THREAD_STATE_IDLE)
232        host_info_processor [cpu].cpu_ticks [PROCESSOR_INFO_STATE_IDLE]++;
233      else
234        host_info_processor [cpu].cpu_ticks [PROCESSOR_INFO_STATE_SYSTEM]++;
235    
236    if (CPU_CURRENT () == master_cpu)    if (CPU_CURRENT () == master_cpu)
237      {      {
238        /* Increase timestamp counter.  */        /* Increase timestamp counter.  */

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

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