Ignore:
File:
1 edited

Legend:

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

    rae0300b5 rc0699467  
    3939#include <proc/thread.h>
    4040#include <proc/task.h>
    41 #include <proc/uarg.h>
    4241#include <mm/frame.h>
    4342#include <mm/page.h>
     
    4544#include <arch/cycle.h>
    4645#include <arch.h>
    47 #include <synch/synch.h>
    4846#include <synch/spinlock.h>
    4947#include <synch/waitq.h>
     
    5553#include <time/clock.h>
    5654#include <time/timeout.h>
     55#include <time/delay.h>
    5756#include <config.h>
    5857#include <arch/interrupt.h>
     
    6766#include <syscall/copy.h>
    6867#include <errno.h>
    69 
    70 
    71 #ifndef LOADED_PROG_STACK_PAGES_NO
    72 #define LOADED_PROG_STACK_PAGES_NO 1
    73 #endif
    74 
    7568
    7669/** Thread states */
     
    265258         */
    266259       
    267         list_append(&thread->rq_link, &cpu->rq[i].rq_head);
     260        list_append(&thread->rq_link, &cpu->rq[i].rq);
    268261        cpu->rq[i].n++;
    269262        irq_spinlock_unlock(&(cpu->rq[i].lock), true);
     
    300293       
    301294        /* Not needed, but good for debugging */
    302         memsetb(thread->kstack, THREAD_STACK_SIZE * 1 << STACK_FRAMES, 0);
     295        memsetb(thread->kstack, STACK_SIZE, 0);
    303296       
    304297        irq_spinlock_lock(&tidlock, true);
     
    308301        context_save(&thread->saved_context);
    309302        context_set(&thread->saved_context, FADDR(cushion),
    310             (uintptr_t) thread->kstack, THREAD_STACK_SIZE);
     303            (uintptr_t) thread->kstack, STACK_SIZE);
    311304       
    312305        the_initialize((the_t *) thread->kstack);
     
    327320        thread->cpu = NULL;
    328321        thread->flags = flags;
     322        thread->nomigrate = 0;
    329323        thread->state = Entering;
    330324       
     
    427421                atomic_inc(&task->lifecount);
    428422       
    429         list_append(&thread->th_link, &task->th_head);
     423        list_append(&thread->th_link, &task->threads);
    430424       
    431425        irq_spinlock_pass(&task->lock, &threads_lock);
     
    489483}
    490484
     485/** Prevent the current thread from being migrated to another processor. */
     486void thread_migration_disable(void)
     487{
     488        ASSERT(THREAD);
     489
     490        THREAD->nomigrate++;
     491}
     492
     493/** Allow the current thread to be migrated to another processor. */
     494void thread_migration_enable(void)
     495{
     496        ASSERT(THREAD);
     497        ASSERT(THREAD->nomigrate > 0);
     498
     499        THREAD->nomigrate--;
     500}
     501
    491502/** Thread sleep
    492503 *
     
    605616                printf("%-8" PRIu64 " %-14s %10p %-8s %10p %-5" PRIu32 "\n",
    606617                    thread->tid, name, thread, thread_states[thread->state],
    607                     thread->task, thread->task->context);
     618                    thread->task, thread->task->container);
    608619#endif
    609620       
     
    617628                printf("%-8" PRIu64 " %-14s %18p %-8s %18p %-5" PRIu32 "\n",
    618629                    thread->tid, name, thread, thread_states[thread->state],
    619                     thread->task, thread->task->context);
     630                    thread->task, thread->task->container);
    620631#endif
    621632       
     
    658669        else
    659670                printf("[id    ] [name        ] [address ] [state ] [task    ]"
    660                     " [ctx]\n");
     671                    " [ctn]\n");
    661672#endif
    662673       
     
    667678        } else
    668679                printf("[id    ] [name        ] [address         ] [state ]"
    669                     " [task            ] [ctx]\n");
     680                    " [task            ] [ctn]\n");
    670681#endif
    671682       
     
    918929}
    919930
     931sysarg_t sys_thread_udelay(uint32_t usec)
     932{
     933        delay(usec);
     934        return 0;
     935}
     936
    920937/** @}
    921938 */
Note: See TracChangeset for help on using the changeset viewer.