Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • kernel/generic/src/proc/scheduler.c

    rdf58e44 r55b77d9  
    102102#endif
    103103       
     104#ifdef CONFIG_UDEBUG
    104105        if (THREAD->btrace) {
    105106                istate_t *istate = THREAD->udebug.uspace_state;
     
    111112                THREAD->btrace = false;
    112113        }
     114#endif
    113115}
    114116
     
    235237                 * Take the first thread from the queue.
    236238                 */
    237                 thread_t *thread =
    238                     list_get_instance(CPU->rq[i].rq_head.next, thread_t, rq_link);
     239                thread_t *thread = list_get_instance(
     240                    list_first(&CPU->rq[i].rq), thread_t, rq_link);
    239241                list_remove(&thread->rq_link);
    240242               
     
    271273static void relink_rq(int start)
    272274{
    273         link_t head;
    274        
    275         list_initialize(&head);
     275        list_t list;
     276       
     277        list_initialize(&list);
    276278        irq_spinlock_lock(&CPU->lock, false);
    277279       
     
    282284                       
    283285                        irq_spinlock_lock(&CPU->rq[i + 1].lock, false);
    284                         list_concat(&head, &CPU->rq[i + 1].rq_head);
     286                        list_concat(&list, &CPU->rq[i + 1].rq);
    285287                        size_t n = CPU->rq[i + 1].n;
    286288                        CPU->rq[i + 1].n = 0;
     
    290292                       
    291293                        irq_spinlock_lock(&CPU->rq[i].lock, false);
    292                         list_concat(&CPU->rq[i].rq_head, &head);
     294                        list_concat(&CPU->rq[i].rq, &list);
    293295                        CPU->rq[i].n += n;
    294296                        irq_spinlock_unlock(&CPU->rq[i].lock, false);
     
    352354       
    353355        /*
    354          * Through the 'THE' structure, we keep track of THREAD, TASK, CPU, VM
     356         * Through the 'THE' structure, we keep track of THREAD, TASK, CPU, AS
    355357         * and preemption counter. At this point THE could be coming either
    356358         * from THREAD's or CPU's stack.
     
    374376        context_save(&CPU->saved_context);
    375377        context_set(&CPU->saved_context, FADDR(scheduler_separated_stack),
    376             (uintptr_t) CPU->stack, CPU_STACK_SIZE);
     378            (uintptr_t) CPU->stack, STACK_SIZE);
    377379        context_restore(&CPU->saved_context);
    378380       
     
    584586         * Searching least priority queues on all CPU's first and most priority
    585587         * queues on all CPU's last.
    586          *
    587588         */
    588589        size_t acpu;
     
    615616                       
    616617                        /* Search rq from the back */
    617                         link_t *link = cpu->rq[rq].rq_head.prev;
    618                        
    619                         while (link != &(cpu->rq[rq].rq_head)) {
    620                                 thread = (thread_t *) list_get_instance(link, thread_t, rq_link);
     618                        link_t *link = cpu->rq[rq].rq.head.prev;
     619                       
     620                        while (link != &(cpu->rq[rq].rq.head)) {
     621                                thread = (thread_t *) list_get_instance(link,
     622                                    thread_t, rq_link);
    621623                               
    622624                                /*
    623                                  * We don't want to steal CPU-wired threads
    624                                  * neither threads already stolen. The latter
    625                                  * prevents threads from migrating between CPU's
    626                                  * without ever being run. We don't want to
    627                                  * steal threads whose FPU context is still in
    628                                  * CPU.
    629                                  *
     625                                 * Do not steal CPU-wired threads, threads
     626                                 * already stolen, threads for which migration
     627                                 * was temporarily disabled or threads whose
     628                                 * FPU context is still in the CPU.
    630629                                 */
    631630                                irq_spinlock_lock(&thread->lock, false);
    632631                               
    633                                 if ((!(thread->flags & (THREAD_FLAG_WIRED | THREAD_FLAG_STOLEN)))
    634                                     && (!(thread->fpu_context_engaged))) {
     632                                if (!(thread->flags & THREAD_FLAG_WIRED) &&
     633                                    !(thread->flags & THREAD_FLAG_STOLEN) &&
     634                                    !thread->nomigrate &&
     635                                    !thread->fpu_context_engaged) {
    635636                                        /*
    636637                                         * Remove thread from ready queue.
    637638                                         */
    638                                         irq_spinlock_unlock(&thread->lock, false);
     639                                        irq_spinlock_unlock(&thread->lock,
     640                                            false);
    639641                                       
    640642                                        atomic_dec(&cpu->nrdy);
     
    658660                                 */
    659661                               
    660                                 irq_spinlock_pass(&(cpu->rq[rq].lock), &thread->lock);
     662                                irq_spinlock_pass(&(cpu->rq[rq].lock),
     663                                    &thread->lock);
    661664                               
    662665#ifdef KCPULB_VERBOSE
     
    737740                       
    738741                        printf("\trq[%u]: ", i);
    739                         link_t *cur;
    740                         for (cur = cpus[cpu].rq[i].rq_head.next;
    741                             cur != &(cpus[cpu].rq[i].rq_head);
    742                             cur = cur->next) {
    743                                 thread_t *thread = list_get_instance(cur, thread_t, rq_link);
     742                        list_foreach(cpus[cpu].rq[i].rq, cur) {
     743                                thread_t *thread = list_get_instance(cur,
     744                                    thread_t, rq_link);
    744745                                printf("%" PRIu64 "(%s) ", thread->tid,
    745746                                    thread_states[thread->state]);
Note: See TracChangeset for help on using the changeset viewer.