/[rtmk]/rtmk/sched-fifo.c
ViewVC logotype

Diff of /rtmk/sched-fifo.c

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

revision 1.1 by jrydberg, Thu Jan 3 01:32:43 2002 UTC revision 1.2 by jrydberg, Mon Jan 7 02:50:17 2002 UTC
# Line 32  fifo_select (struct sched_policy *sp, st Line 32  fifo_select (struct sched_policy *sp, st
32    
33    /* If RUN_MAP is zero - there is no available threads in this policy.  */    /* If RUN_MAP is zero - there is no available threads in this policy.  */
34    
35      spin_lock (&sp->interlock);
36    if (! sp->run_map)    if (! sp->run_map)
37      return 0;      {
38          spin_unlock (&sp->interlock);
39          return 0;
40        }
41    
42    /* Remove thread with highest priority from thread, and update the queue    /* Remove thread with highest priority from thread, and update the queue
43       map if the queue became empty.  */       map if the queue became empty.  */
# Line 51  fifo_select (struct sched_policy *sp, st Line 55  fifo_select (struct sched_policy *sp, st
55    empty_p = queue_empty (&sp->run_queues [whichq]);    empty_p = queue_empty (&sp->run_queues [whichq]);
56    --sp->run_count;    --sp->run_count;
57    sp->run_map &= ~((!! empty_p) << whichq); /* ??? optimize?  */    sp->run_map &= ~((!! empty_p) << whichq); /* ??? optimize?  */
58      spin_unlock (&sp->interlock);
59    
60    thread->runq_list = 0;    thread->runq_list = 0;
61    return thread;    return thread;
# Line 67  fifo_add (struct sched_policy *sp, struc Line 72  fifo_add (struct sched_policy *sp, struc
72    
73    /* Insert thread into scheduling policy's run queue and update RUN_MAP.  */    /* Insert thread into scheduling policy's run queue and update RUN_MAP.  */
74    
75      spin_lock (&sp->interlock);
76    whichq = (15 - thread->sched_priority);    whichq = (15 - thread->sched_priority);
77    queue_enter (&sp->run_queues [whichq], thread, struct thread *, runq);    queue_enter (&sp->run_queues [whichq], thread, struct thread *, runq);
78    thread->runq_list = &sp->run_queues [whichq];    thread->runq_list = &sp->run_queues [whichq];
# Line 79  fifo_add (struct sched_policy *sp, struc Line 85  fifo_add (struct sched_policy *sp, struc
85    if (may_preempt_p)    if (may_preempt_p)
86      {      {
87        if (THREAD_CURRENT()->sched_premul < thread->sched_premul)        if (THREAD_CURRENT()->sched_premul < thread->sched_premul)
88          return may_preempt_p;          {
89              spin_unlock (&sp->interlock);
90              return may_preempt_p;
91            }
92      }      }
93    
94      spin_unlock (&sp->interlock);
95    return false;    return false;
96  }  }
97    
# Line 95  fifo_remove (struct sched_policy *sp, st Line 105  fifo_remove (struct sched_policy *sp, st
105    
106    /* Insert thread into scheduling policy's run queue and update RUN_MAP.  */    /* Insert thread into scheduling policy's run queue and update RUN_MAP.  */
107    
108      spin_lock (&sp->interlock);
109    whichq = thread->sched_priority;    whichq = thread->sched_priority;
110    queue_remove (&sp->run_queues [whichq], thread, struct thread *, runq);    queue_remove (&sp->run_queues [whichq], thread, struct thread *, runq);
111    empty_p = queue_empty (&sp->run_queues[whichq]);    empty_p = queue_empty (&sp->run_queues[whichq]);
# Line 102  fifo_remove (struct sched_policy *sp, st Line 113  fifo_remove (struct sched_policy *sp, st
113    
114    --sp->run_count;    --sp->run_count;
115    sp->run_map &= ~((!! empty_p) << whichq);    sp->run_map &= ~((!! empty_p) << whichq);
116      spin_unlock (&sp->interlock);
117  }  }
118    
119  /* Scheduling decisions at periodic clock tick.  Returns true if we should  /* Scheduling decisions at periodic clock tick.  Returns true if we should
# Line 120  fifo_clock (struct sched_policy *sp, str Line 132  fifo_clock (struct sched_policy *sp, str
132  static bool  static bool
133  fifo_preempt_p (struct sched_policy *sp, struct thread *thread)  fifo_preempt_p (struct sched_policy *sp, struct thread *thread)
134  {  {
135      spin_lock (&sp->interlock);
136    if (! sp->run_map)    if (! sp->run_map)
137      return false;      {
138          spin_unlock (&sp->interlock);
139          return false;
140        }
141    
142    if (thread->sched_policy < sp->policy_index)    if (thread->sched_policy < sp->policy_index)
143      return true;      {
144          spin_unlock (&sp->interlock);
145          return true;
146        }
147    
148    if ((ffs (sp->run_map) - 1) > (15 - thread->sched_priority))    if ((ffs (sp->run_map) - 1) > (15 - thread->sched_priority))
149      return true;      {
150          spin_unlock (&sp->interlock);
151          return true;
152        }
153    
154      spin_unlock (&sp->interlock);
155    return false;    return false;
156  }  }
157    

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.2

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