Changeset 380553c in mainline


Ignore:
Timestamp:
2012-06-21T10:49:44Z (12 years ago)
Author:
Frantisek Princ <frantisek.princ@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
d510ac01
Parents:
2616a75b (diff), f22dc820 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge with mainline

Files:
33 edited

Legend:

Unmodified
Added
Removed
  • kernel/arch/ia64/src/drivers/ski.c

    r2616a75b r380553c  
    150150       
    151151        if (instance) {
    152                 instance->thread = thread_create(kskipoll, instance, TASK, 0,
    153                     "kskipoll", true);
     152                instance->thread = thread_create(kskipoll, instance, TASK,
     153                    THREAD_FLAG_UNCOUNTED, "kskipoll");
    154154               
    155155                if (!instance->thread) {
  • kernel/arch/sparc64/src/drivers/niagara.c

    r2616a75b r380553c  
    184184       
    185185        instance = malloc(sizeof(niagara_instance_t), FRAME_ATOMIC);
    186         instance->thread = thread_create(kniagarapoll, NULL, TASK, 0,
    187             "kniagarapoll", true);
     186        instance->thread = thread_create(kniagarapoll, NULL, TASK,
     187            THREAD_FLAG_UNCOUNTED, "kniagarapoll");
    188188       
    189189        if (!instance->thread) {
  • kernel/arch/sparc64/src/proc/sun4u/scheduler.c

    r2616a75b r380553c  
    5151void before_thread_runs_arch(void)
    5252{
    53         if ((THREAD->flags & THREAD_FLAG_USPACE)) {
     53        if (THREAD->uspace) {
    5454                /*
    5555                 * Write kernel stack address to %g6 of the alternate and
     
    7474void after_thread_ran_arch(void)
    7575{
    76         if ((THREAD->flags & THREAD_FLAG_USPACE)) {
    77                 /* sample the state of the userspace window buffer */   
     76        if (THREAD->uspace) {
     77                /* sample the state of the userspace window buffer */
    7878                THREAD->arch.uspace_window_buffer = (uint8_t *) read_from_ag_g7();
    7979        }
  • kernel/arch/sparc64/src/proc/sun4v/scheduler.c

    r2616a75b r380553c  
    5454void before_thread_runs_arch(void)
    5555{
    56         if ((THREAD->flags & THREAD_FLAG_USPACE)) {
     56        if (THREAD->uspace) {
    5757                uint64_t sp = (uintptr_t) THREAD->kstack + STACK_SIZE -
    5858                    (STACK_BIAS + ALIGN_UP(STACK_ITEM_SIZE, STACK_ALIGNMENT));
     
    6666void after_thread_ran_arch(void)
    6767{
    68         if ((THREAD->flags & THREAD_FLAG_USPACE)) {
    69                 /* sample the state of the userspace window buffer */   
     68        if (THREAD->uspace) {
     69                /* sample the state of the userspace window buffer */
    7070                THREAD->arch.uspace_window_buffer =
    7171                    (uint8_t *) asi_u64_read(ASI_SCRATCHPAD, SCRATCHPAD_WBUF);
  • kernel/arch/sparc64/src/proc/thread.c

    r2616a75b r380553c  
    6161void thread_create_arch(thread_t *t)
    6262{
    63         if ((t->flags & THREAD_FLAG_USPACE) && (!t->arch.uspace_window_buffer))
     63        if ((t->uspace) && (!t->arch.uspace_window_buffer))
    6464                {
    6565                /*
  • kernel/genarch/src/kbrd/kbrd.c

    r2616a75b r380553c  
    158158            = malloc(sizeof(kbrd_instance_t), FRAME_ATOMIC);
    159159        if (instance) {
    160                 instance->thread
    161                         = thread_create(kkbrd, (void *) instance, TASK, 0, "kkbrd", false);
     160                instance->thread = thread_create(kkbrd, (void *) instance,
     161                    TASK, THREAD_FLAG_NONE, "kkbrd");
    162162               
    163163                if (!instance->thread) {
  • kernel/genarch/src/mm/as_ht.c

    r2616a75b r380553c  
    7878                hash_table_create(&page_ht, PAGE_HT_ENTRIES, 2, &ht_operations);
    7979                mutex_initialize(&page_ht_lock, MUTEX_PASSIVE);
    80                 pte_cache = slab_cache_create("pte_cache", sizeof(pte_t), 0, NULL, NULL,
    81                     SLAB_CACHE_MAGDEFERRED);
     80                pte_cache = slab_cache_create("pte_t", sizeof(pte_t), 0,
     81                    NULL, NULL, SLAB_CACHE_MAGDEFERRED);
    8282        }
    8383       
  • kernel/genarch/src/srln/srln.c

    r2616a75b r380553c  
    130130            = malloc(sizeof(srln_instance_t), FRAME_ATOMIC);
    131131        if (instance) {
    132                 instance->thread
    133                         = thread_create(ksrln, (void *) instance, TASK, 0, "ksrln", false);
     132                instance->thread = thread_create(ksrln, (void *) instance,
     133                    TASK, THREAD_FLAG_NONE, "ksrln");
    134134               
    135135                if (!instance->thread) {
  • kernel/generic/include/proc/thread.h

    r2616a75b r380553c  
    5454
    5555/* Thread flags */
    56 
    57 /** Thread cannot be migrated to another CPU.
    58  *
    59  * When using this flag, the caller must set cpu in the thread_t
    60  * structure manually before calling thread_ready (even on uniprocessor).
    61  *
    62  */
    63 #define THREAD_FLAG_WIRED  (1 << 0)
    64 
    65 /** Thread was migrated to another CPU and has not run yet. */
    66 #define THREAD_FLAG_STOLEN  (1 << 1)
    67 
    68 /** Thread executes in userspace. */
    69 #define THREAD_FLAG_USPACE  (1 << 2)
    70 
    71 /** Thread will be attached by the caller. */
    72 #define THREAD_FLAG_NOATTACH  (1 << 3)
     56typedef enum {
     57        THREAD_FLAG_NONE = 0,
     58        /** Thread executes in user space. */
     59        THREAD_FLAG_USPACE = (1 << 0),
     60        /** Thread will be attached by the caller. */
     61        THREAD_FLAG_NOATTACH = (1 << 1),
     62        /** Thread accounting doesn't affect accumulated task accounting. */
     63        THREAD_FLAG_UNCOUNTED = (1 << 2)
     64} thread_flags_t;
    7365
    7466/** Thread structure. There is one per thread. */
     
    147139       
    148140        fpu_context_t *saved_fpu_context;
    149         int fpu_context_exists;
     141        bool fpu_context_exists;
    150142       
    151143        /*
     
    154146         * thread. This disables migration.
    155147         */
    156         int fpu_context_engaged;
     148        bool fpu_context_engaged;
    157149       
    158150        /* The thread will not be migrated if nomigrate is non-zero. */
    159         int nomigrate;
    160        
    161         /** Thread's state. */
     151        unsigned int nomigrate;
     152       
     153        /** Thread state. */
    162154        state_t state;
    163         /** Thread's flags. */
    164         unsigned int flags;
    165        
    166         /** Thread's CPU. */
     155       
     156        /** Thread CPU. */
    167157        cpu_t *cpu;
    168158        /** Containing task. */
    169159        task_t *task;
     160        /** Thread is wired to CPU. */
     161        bool wired;
     162        /** Thread was migrated to another CPU and has not run yet. */
     163        bool stolen;
     164        /** Thread is executed in user space. */
     165        bool uspace;
    170166       
    171167        /** Ticks before preemption. */
     
    216212extern void thread_init(void);
    217213extern thread_t *thread_create(void (*)(void *), void *, task_t *,
    218     unsigned int, const char *, bool);
     214    thread_flags_t, const char *);
     215extern void thread_wire(thread_t *, cpu_t *);
    219216extern void thread_attach(thread_t *, task_t *);
    220217extern void thread_ready(thread_t *);
  • kernel/generic/src/adt/btree.c

    r2616a75b r380553c  
    7171void btree_init(void)
    7272{
    73         btree_node_slab = slab_cache_create("btree_node_slab",
     73        btree_node_slab = slab_cache_create("btree_node_t",
    7474            sizeof(btree_node_t), 0, NULL, NULL, SLAB_CACHE_MAGDEFERRED);
    7575}
  • kernel/generic/src/console/cmd.c

    r2616a75b r380553c  
    724724                thread_t *thread;
    725725                if ((thread = thread_create((void (*)(void *)) cmd_call0,
    726                     (void *) argv, TASK, THREAD_FLAG_WIRED, "call0", false))) {
    727                         irq_spinlock_lock(&thread->lock, true);
    728                         thread->cpu = &cpus[i];
    729                         irq_spinlock_unlock(&thread->lock, true);
    730                        
     726                    (void *) argv, TASK, THREAD_FLAG_NONE, "call0"))) {
    731727                        printf("cpu%u: ", i);
    732                        
     728                        thread_wire(thread, &cpus[i]);
    733729                        thread_ready(thread);
    734730                        thread_join(thread);
  • kernel/generic/src/ipc/ipc.c

    r2616a75b r380553c  
    670670void ipc_init(void)
    671671{
    672         ipc_call_slab = slab_cache_create("ipc_call", sizeof(call_t), 0, NULL,
     672        ipc_call_slab = slab_cache_create("call_t", sizeof(call_t), 0, NULL,
    673673            NULL, 0);
    674         ipc_answerbox_slab = slab_cache_create("ipc_answerbox",
     674        ipc_answerbox_slab = slab_cache_create("answerbox_t",
    675675            sizeof(answerbox_t), 0, NULL, NULL, 0);
    676676}
  • kernel/generic/src/ipc/kbox.c

    r2616a75b r380553c  
    244244       
    245245        /* Create a kbox thread */
    246         thread_t *kb_thread = thread_create(kbox_thread_proc, NULL, task, 0,
    247             "kbox", false);
     246        thread_t *kb_thread = thread_create(kbox_thread_proc, NULL, task,
     247            THREAD_FLAG_NONE, "kbox");
    248248        if (!kb_thread) {
    249249                mutex_unlock(&task->kb.cleanup_lock);
  • kernel/generic/src/lib/ra.c

    r2616a75b r380553c  
    424424void ra_init(void)
    425425{
    426         ra_segment_cache = slab_cache_create("segment_cache",
     426        ra_segment_cache = slab_cache_create("ra_segment_t",
    427427            sizeof(ra_segment_t), 0, NULL, NULL, SLAB_CACHE_MAGDEFERRED);
    428428}
  • kernel/generic/src/main/kinit.c

    r2616a75b r380553c  
    116116                 * Just a beautification.
    117117                 */
    118                 thread = thread_create(kmp, NULL, TASK, THREAD_FLAG_WIRED, "kmp", true);
     118                thread = thread_create(kmp, NULL, TASK,
     119                    THREAD_FLAG_UNCOUNTED, "kmp");
    119120                if (thread != NULL) {
    120                         irq_spinlock_lock(&thread->lock, false);
    121                         thread->cpu = &cpus[0];
    122                         irq_spinlock_unlock(&thread->lock, false);
     121                        thread_wire(thread, &cpus[0]);
    123122                        thread_ready(thread);
    124123                } else
     
    134133               
    135134                for (i = 0; i < config.cpu_count; i++) {
    136                         thread = thread_create(kcpulb, NULL, TASK, THREAD_FLAG_WIRED, "kcpulb", true);
     135                        thread = thread_create(kcpulb, NULL, TASK,
     136                            THREAD_FLAG_UNCOUNTED, "kcpulb");
    137137                        if (thread != NULL) {
    138                                 irq_spinlock_lock(&thread->lock, false);
    139                                 thread->cpu = &cpus[i];
    140                                 irq_spinlock_unlock(&thread->lock, false);
     138                                thread_wire(thread, &cpus[i]);
    141139                                thread_ready(thread);
    142140                        } else
     
    152150       
    153151        /* Start thread computing system load */
    154         thread = thread_create(kload, NULL, TASK, 0, "kload", false);
     152        thread = thread_create(kload, NULL, TASK, THREAD_FLAG_NONE,
     153            "kload");
    155154        if (thread != NULL)
    156155                thread_ready(thread);
     
    163162                 * Create kernel console.
    164163                 */
    165                 thread = thread_create(kconsole_thread, NULL, TASK, 0, "kconsole", false);
     164                thread = thread_create(kconsole_thread, NULL, TASK,
     165                    THREAD_FLAG_NONE, "kconsole");
    166166                if (thread != NULL)
    167167                        thread_ready(thread);
  • kernel/generic/src/main/main.c

    r2616a75b r380553c  
    276276         * Create the first thread.
    277277         */
    278         thread_t *kinit_thread =
    279             thread_create(kinit, NULL, kernel, 0, "kinit", true);
     278        thread_t *kinit_thread = thread_create(kinit, NULL, kernel,
     279            THREAD_FLAG_UNCOUNTED, "kinit");
    280280        if (!kinit_thread)
    281281                panic("Cannot create kinit thread.");
  • kernel/generic/src/mm/as.c

    r2616a75b r380553c  
    130130        as_arch_init();
    131131       
    132         as_slab = slab_cache_create("as_slab", sizeof(as_t), 0,
     132        as_slab = slab_cache_create("as_t", sizeof(as_t), 0,
    133133            as_constructor, as_destructor, SLAB_CACHE_MAGDEFERRED);
    134134       
  • kernel/generic/src/mm/slab.c

    r2616a75b r380553c  
    891891{
    892892        /* Initialize magazine cache */
    893         _slab_cache_create(&mag_cache, "slab_magazine",
     893        _slab_cache_create(&mag_cache, "slab_magazine_t",
    894894            sizeof(slab_magazine_t) + SLAB_MAG_SIZE * sizeof(void*),
    895895            sizeof(uintptr_t), NULL, NULL, SLAB_CACHE_NOMAGAZINE |
     
    897897       
    898898        /* Initialize slab_cache cache */
    899         _slab_cache_create(&slab_cache_cache, "slab_cache",
     899        _slab_cache_create(&slab_cache_cache, "slab_cache_cache",
    900900            sizeof(slab_cache_cache), sizeof(uintptr_t), NULL, NULL,
    901901            SLAB_CACHE_NOMAGAZINE | SLAB_CACHE_SLINSIDE);
    902902       
    903903        /* Initialize external slab cache */
    904         slab_extern_cache = slab_cache_create("slab_extern", sizeof(slab_t), 0,
     904        slab_extern_cache = slab_cache_create("slab_t", sizeof(slab_t), 0,
    905905            NULL, NULL, SLAB_CACHE_SLINSIDE | SLAB_CACHE_MAGDEFERRED);
    906906       
  • kernel/generic/src/proc/program.c

    r2616a75b r380553c  
    102102         */
    103103        prg->main_thread = thread_create(uinit, kernel_uarg, prg->task,
    104             THREAD_FLAG_USPACE, "uinit", false);
     104            THREAD_FLAG_USPACE, "uinit");
    105105        if (!prg->main_thread) {
    106106                free(kernel_uarg);
  • kernel/generic/src/proc/scheduler.c

    r2616a75b r380553c  
    9898        else {
    9999                fpu_init();
    100                 THREAD->fpu_context_exists = 1;
     100                THREAD->fpu_context_exists = true;
    101101        }
    102102#endif
     
    142142               
    143143                /* Don't prevent migration */
    144                 CPU->fpu_owner->fpu_context_engaged = 0;
     144                CPU->fpu_owner->fpu_context_engaged = false;
    145145                irq_spinlock_unlock(&CPU->fpu_owner->lock, false);
    146146                CPU->fpu_owner = NULL;
     
    163163                }
    164164                fpu_init();
    165                 THREAD->fpu_context_exists = 1;
     165                THREAD->fpu_context_exists = true;
    166166        }
    167167       
    168168        CPU->fpu_owner = THREAD;
    169         THREAD->fpu_context_engaged = 1;
     169        THREAD->fpu_context_engaged = true;
    170170        irq_spinlock_unlock(&THREAD->lock, false);
    171171       
     
    248248               
    249249                /*
    250                  * Clear the THREAD_FLAG_STOLEN flag so that t can be migrated
     250                 * Clear the stolen flag so that it can be migrated
    251251                 * when load balancing needs emerge.
    252252                 */
    253                 thread->flags &= ~THREAD_FLAG_STOLEN;
     253                thread->stolen = false;
    254254                irq_spinlock_unlock(&thread->lock, false);
    255255               
     
    630630                                irq_spinlock_lock(&thread->lock, false);
    631631                               
    632                                 if (!(thread->flags & THREAD_FLAG_WIRED) &&
    633                                     !(thread->flags & THREAD_FLAG_STOLEN) &&
    634                                     !thread->nomigrate &&
    635                                     !thread->fpu_context_engaged) {
     632                                if ((!thread->wired) && (!thread->stolen) &&
     633                                    (!thread->nomigrate) &&
     634                                    (!thread->fpu_context_engaged)) {
    636635                                        /*
    637636                                         * Remove thread from ready queue.
     
    670669#endif
    671670                               
    672                                 thread->flags |= THREAD_FLAG_STOLEN;
     671                                thread->stolen = true;
    673672                                thread->state = Entering;
    674673                               
  • kernel/generic/src/proc/task.c

    r2616a75b r380553c  
    9090        TASK = NULL;
    9191        avltree_create(&tasks_tree);
    92         task_slab = slab_cache_create("task_slab", sizeof(task_t), 0,
     92        task_slab = slab_cache_create("task_t", sizeof(task_t), 0,
    9393            tsk_constructor, NULL, 0);
    9494}
  • kernel/generic/src/proc/thread.c

    r2616a75b r380553c  
    191191        kmflags |= FRAME_LOWMEM;
    192192        kmflags &= ~FRAME_HIGHMEM;
    193 
     193       
    194194        thread->kstack = (uint8_t *) frame_alloc(STACK_FRAMES, FRAME_KA | kmflags);
    195195        if (!thread->kstack) {
     
    236236       
    237237        atomic_set(&nrdy, 0);
    238         thread_slab = slab_cache_create("thread_slab", sizeof(thread_t), 0,
     238        thread_slab = slab_cache_create("thread_t", sizeof(thread_t), 0,
    239239            thr_constructor, thr_destructor, 0);
    240240       
    241241#ifdef CONFIG_FPU
    242         fpu_context_slab = slab_cache_create("fpu_slab", sizeof(fpu_context_t),
    243             FPU_CONTEXT_ALIGN, NULL, NULL, 0);
     242        fpu_context_slab = slab_cache_create("fpu_context_t",
     243            sizeof(fpu_context_t), FPU_CONTEXT_ALIGN, NULL, NULL, 0);
    244244#endif
    245245       
     
    247247}
    248248
     249/** Wire thread to the given CPU
     250 *
     251 * @param cpu CPU to wire the thread to.
     252 *
     253 */
     254void thread_wire(thread_t *thread, cpu_t *cpu)
     255{
     256        irq_spinlock_lock(&thread->lock, true);
     257        thread->cpu = cpu;
     258        thread->wired = true;
     259        irq_spinlock_unlock(&thread->lock, true);
     260}
     261
    249262/** Make thread ready
    250263 *
     
    260273        ASSERT(thread->state != Ready);
    261274       
    262         int i = (thread->priority < RQ_COUNT - 1)
    263             ? ++thread->priority : thread->priority;
    264        
    265         cpu_t *cpu = CPU;
    266         if (thread->flags & THREAD_FLAG_WIRED) {
     275        int i = (thread->priority < RQ_COUNT - 1) ?
     276            ++thread->priority : thread->priority;
     277       
     278        cpu_t *cpu;
     279        if (thread->wired || thread->nomigrate || thread->fpu_context_engaged) {
    267280                ASSERT(thread->cpu != NULL);
    268281                cpu = thread->cpu;
    269         }
     282        } else
     283                cpu = CPU;
     284       
    270285        thread->state = Ready;
    271286       
     
    298313 * @param flags     Thread flags.
    299314 * @param name      Symbolic name (a copy is made).
    300  * @param uncounted Thread's accounting doesn't affect accumulated task
    301  *                  accounting.
    302315 *
    303316 * @return New thread's structure on success, NULL on failure.
     
    305318 */
    306319thread_t *thread_create(void (* func)(void *), void *arg, task_t *task,
    307     unsigned int flags, const char *name, bool uncounted)
     320    thread_flags_t flags, const char *name)
    308321{
    309322        thread_t *thread = (thread_t *) slab_alloc(thread_slab, 0);
     
    335348        thread->ucycles = 0;
    336349        thread->kcycles = 0;
    337         thread->uncounted = uncounted;
     350        thread->uncounted =
     351            ((flags & THREAD_FLAG_UNCOUNTED) == THREAD_FLAG_UNCOUNTED);
    338352        thread->priority = -1;          /* Start in rq[0] */
    339353        thread->cpu = NULL;
    340         thread->flags = flags;
     354        thread->wired = false;
     355        thread->stolen = false;
     356        thread->uspace =
     357            ((flags & THREAD_FLAG_USPACE) == THREAD_FLAG_USPACE);
     358       
    341359        thread->nomigrate = 0;
    342360        thread->state = Entering;
     
    356374        thread->task = task;
    357375       
    358         thread->fpu_context_exists = 0;
    359         thread->fpu_context_engaged = 0;
     376        thread->fpu_context_exists = false;
     377        thread->fpu_context_engaged = false;
    360378       
    361379        avltree_node_initialize(&thread->threads_tree_node);
     
    371389        thread_create_arch(thread);
    372390       
    373         if (!(flags & THREAD_FLAG_NOATTACH))
     391        if ((flags & THREAD_FLAG_NOATTACH) != THREAD_FLAG_NOATTACH)
    374392                thread_attach(thread, task);
    375393       
     
    437455       
    438456        /* Must not count kbox thread into lifecount */
    439         if (thread->flags & THREAD_FLAG_USPACE)
     457        if (thread->uspace)
    440458                atomic_inc(&task->lifecount);
    441459       
     
    459477void thread_exit(void)
    460478{
    461         if (THREAD->flags & THREAD_FLAG_USPACE) {
     479        if (THREAD->uspace) {
    462480#ifdef CONFIG_UDEBUG
    463481                /* Generate udebug THREAD_E event */
    464482                udebug_thread_e_event();
    465 
     483               
    466484                /*
    467485                 * This thread will not execute any code or system calls from
     
    506524{
    507525        ASSERT(THREAD);
    508 
     526       
    509527        THREAD->nomigrate++;
    510528}
     
    515533        ASSERT(THREAD);
    516534        ASSERT(THREAD->nomigrate > 0);
    517 
    518         THREAD->nomigrate--;
     535       
     536        if (THREAD->nomigrate > 0)
     537                THREAD->nomigrate--;
    519538}
    520539
     
    865884       
    866885        thread_t *thread = thread_create(uinit, kernel_uarg, TASK,
    867             THREAD_FLAG_USPACE | THREAD_FLAG_NOATTACH, namebuf, false);
     886            THREAD_FLAG_USPACE | THREAD_FLAG_NOATTACH, namebuf);
    868887        if (thread) {
    869888                if (uspace_thread_id != NULL) {
  • kernel/generic/src/sysinfo/sysinfo.c

    r2616a75b r380553c  
    9797void sysinfo_init(void)
    9898{
    99         sysinfo_item_slab = slab_cache_create("sysinfo_item_slab",
     99        sysinfo_item_slab = slab_cache_create("sysinfo_item_t",
    100100            sizeof(sysinfo_item_t), 0, sysinfo_item_constructor,
    101101            sysinfo_item_destructor, SLAB_CACHE_MAGDEFERRED);
  • kernel/generic/src/udebug/udebug.c

    r2616a75b r380553c  
    410410               
    411411                mutex_lock(&thread->udebug.lock);
    412                 unsigned int flags = thread->flags;
    413412               
    414413                /* Only process userspace threads. */
    415                 if ((flags & THREAD_FLAG_USPACE) != 0) {
     414                if (thread->uspace) {
    416415                        /* Prevent any further debug activity in thread. */
    417416                        thread->udebug.active = false;
  • kernel/generic/src/udebug/udebug_ops.c

    r2616a75b r380553c  
    9595       
    9696        /* Verify that 'thread' is a userspace thread. */
    97         if ((thread->flags & THREAD_FLAG_USPACE) == 0) {
     97        if (!thread->uspace) {
    9898                /* It's not, deny its existence */
    9999                irq_spinlock_unlock(&thread->lock, true);
     
    200200               
    201201                mutex_lock(&thread->udebug.lock);
    202                 if ((thread->flags & THREAD_FLAG_USPACE) != 0) {
     202                if (thread->uspace) {
    203203                        thread->udebug.active = true;
    204204                        mutex_unlock(&thread->udebug.lock);
     
    393393               
    394394                irq_spinlock_lock(&thread->lock, false);
    395                 int flags = thread->flags;
     395                bool uspace = thread->uspace;
    396396                irq_spinlock_unlock(&thread->lock, false);
    397397               
    398398                /* Not interested in kernel threads. */
    399                 if ((flags & THREAD_FLAG_USPACE) == 0)
     399                if (!uspace)
    400400                        continue;
    401401               
  • kernel/test/mm/falloc1.c

    r2616a75b r380553c  
    3737#include <align.h>
    3838
    39 #define MAX_FRAMES  1024
     39#define MAX_FRAMES  1024U
    4040#define MAX_ORDER   8
    4141#define TEST_RUNS   2
    4242
    43 const char *test_falloc1(void) {
    44         uintptr_t *frames
    45             = (uintptr_t *) malloc(MAX_FRAMES * sizeof(uintptr_t), 0);
    46         int results[MAX_ORDER + 1];
    47        
    48         int i, order, run;
    49         int allocated;
    50        
     43const char *test_falloc1(void)
     44{
    5145        if (TEST_RUNS < 2)
    5246                return "Test is compiled with TEST_RUNS < 2";
    5347       
     48        uintptr_t *frames = (uintptr_t *)
     49            malloc(MAX_FRAMES * sizeof(uintptr_t), 0);
    5450        if (frames == NULL)
    5551                return "Unable to allocate frames";
    5652       
    57         for (run = 0; run < TEST_RUNS; run++) {
    58                 for (order = 0; order <= MAX_ORDER; order++) {
    59                         TPRINTF("Allocating %d frames blocks ... ", 1 << order);
     53        unsigned int results[MAX_ORDER + 1];
     54        for (unsigned int run = 0; run < TEST_RUNS; run++) {
     55                for (unsigned int order = 0; order <= MAX_ORDER; order++) {
     56                        TPRINTF("Allocating %u frames blocks ... ", 1 << order);
    6057                       
    61                         allocated = 0;
    62                         for (i = 0; i < MAX_FRAMES >> order; i++) {
    63                                 frames[allocated] = (uintptr_t) frame_alloc(order, FRAME_ATOMIC | FRAME_KA);
     58                        unsigned int allocated = 0;
     59                        for (unsigned int i = 0; i < (MAX_FRAMES >> order); i++) {
     60                                frames[allocated] = (uintptr_t)
     61                                    frame_alloc(order, FRAME_ATOMIC | FRAME_KA);
    6462                               
    65                                 if (ALIGN_UP(frames[allocated], FRAME_SIZE << order) != frames[allocated]) {
    66                                         TPRINTF("Block at address %p (size %dK) is not aligned\n",
     63                                if (ALIGN_UP(frames[allocated], FRAME_SIZE << order) !=
     64                                    frames[allocated]) {
     65                                        TPRINTF("Block at address %p (size %u) is not aligned\n",
    6766                                            (void *) frames[allocated], (FRAME_SIZE << order) >> 10);
    6867                                        return "Test failed";
     
    8786                        TPRINTF("Deallocating ... ");
    8887                       
    89                         for (i = 0; i < allocated; i++)
     88                        for (unsigned int i = 0; i < allocated; i++)
    9089                                frame_free(KA2PA(frames[i]));
    9190                       
  • kernel/test/mm/falloc2.c

    r2616a75b r380553c  
    4040#include <arch.h>
    4141
    42 #define MAX_FRAMES  256
     42#define MAX_FRAMES  256U
    4343#define MAX_ORDER   8
    4444
     
    5151static void falloc(void *arg)
    5252{
    53         int order, run, allocated, i;
    5453        uint8_t val = THREAD->tid % THREADS;
    55         size_t k;
    5654       
    57         void **frames =  (void **) malloc(MAX_FRAMES * sizeof(void *), FRAME_ATOMIC);
     55        void **frames = (void **)
     56            malloc(MAX_FRAMES * sizeof(void *), FRAME_ATOMIC);
    5857        if (frames == NULL) {
    59                 TPRINTF("Thread #%" PRIu64 " (cpu%u): Unable to allocate frames\n", THREAD->tid, CPU->id);
     58                TPRINTF("Thread #%" PRIu64 " (cpu%u): "
     59                    "Unable to allocate frames\n", THREAD->tid, CPU->id);
    6060                atomic_inc(&thread_fail);
    6161                atomic_dec(&thread_count);
     
    6565        thread_detach(THREAD);
    6666       
    67         for (run = 0; run < THREAD_RUNS; run++) {
    68                 for (order = 0; order <= MAX_ORDER; order++) {
    69                         TPRINTF("Thread #%" PRIu64 " (cpu%u): Allocating %d frames blocks ... \n", THREAD->tid, CPU->id, 1 << order);
     67        for (unsigned int run = 0; run < THREAD_RUNS; run++) {
     68                for (unsigned int order = 0; order <= MAX_ORDER; order++) {
     69                        TPRINTF("Thread #%" PRIu64 " (cpu%u): "
     70                            "Allocating %u frames blocks ... \n", THREAD->tid,
     71                            CPU->id, 1 << order);
    7072                       
    71                         allocated = 0;
    72                         for (i = 0; i < (MAX_FRAMES >> order); i++) {
    73                                 frames[allocated] = frame_alloc(order, FRAME_ATOMIC | FRAME_KA);
     73                        unsigned int allocated = 0;
     74                        for (unsigned int i = 0; i < (MAX_FRAMES >> order); i++) {
     75                                frames[allocated] =
     76                                    frame_alloc(order, FRAME_ATOMIC | FRAME_KA);
    7477                                if (frames[allocated]) {
    7578                                        memsetb(frames[allocated], FRAME_SIZE << order, val);
     
    7982                        }
    8083                       
    81                         TPRINTF("Thread #%" PRIu64 " (cpu%u): %d blocks allocated.\n", THREAD->tid, CPU->id, allocated);
    82                         TPRINTF("Thread #%" PRIu64 " (cpu%u): Deallocating ... \n", THREAD->tid, CPU->id);
     84                        TPRINTF("Thread #%" PRIu64 " (cpu%u): "
     85                            "%u blocks allocated.\n", THREAD->tid, CPU->id,
     86                            allocated);
     87                        TPRINTF("Thread #%" PRIu64 " (cpu%u): "
     88                            "Deallocating ... \n", THREAD->tid, CPU->id);
    8389                       
    84                         for (i = 0; i < allocated; i++) {
    85                                 for (k = 0; k <= (((size_t) FRAME_SIZE << order) - 1); k++) {
     90                        for (unsigned int i = 0; i < allocated; i++) {
     91                                for (size_t k = 0; k <= (((size_t) FRAME_SIZE << order) - 1);
     92                                    k++) {
    8693                                        if (((uint8_t *) frames[i])[k] != val) {
    87                                                 TPRINTF("Thread #%" PRIu64 " (cpu%u): Unexpected data (%c) in block %p offset %zu\n",
    88                                                     THREAD->tid, CPU->id, ((char *) frames[i])[k], frames[i], k);
     94                                                TPRINTF("Thread #%" PRIu64 " (cpu%u): "
     95                                                    "Unexpected data (%c) in block %p offset %zu\n",
     96                                                    THREAD->tid, CPU->id, ((char *) frames[i])[k],
     97                                                    frames[i], k);
    8998                                                atomic_inc(&thread_fail);
    9099                                                goto cleanup;
     
    94103                        }
    95104                       
    96                         TPRINTF("Thread #%" PRIu64 " (cpu%u): Finished run.\n", THREAD->tid, CPU->id);
     105                        TPRINTF("Thread #%" PRIu64 " (cpu%u): "
     106                            "Finished run.\n", THREAD->tid, CPU->id);
    97107                }
    98108        }
     
    101111        free(frames);
    102112       
    103         TPRINTF("Thread #%" PRIu64 " (cpu%u): Exiting\n", THREAD->tid, CPU->id);
     113        TPRINTF("Thread #%" PRIu64 " (cpu%u): Exiting\n",
     114            THREAD->tid, CPU->id);
    104115        atomic_dec(&thread_count);
    105116}
     
    107118const char *test_falloc2(void)
    108119{
    109         unsigned int i;
    110        
    111120        atomic_set(&thread_count, THREADS);
    112121        atomic_set(&thread_fail, 0);
    113122       
    114         for (i = 0; i < THREADS; i++) {
    115                 thread_t * thrd = thread_create(falloc, NULL, TASK, 0, "falloc", false);
     123        for (unsigned int i = 0; i < THREADS; i++) {
     124                thread_t *thrd = thread_create(falloc, NULL, TASK,
     125                    THREAD_FLAG_NONE, "falloc2");
    116126                if (!thrd) {
    117127                        TPRINTF("Could not create thread %u\n", i);
     
    122132       
    123133        while (atomic_get(&thread_count) > 0) {
    124                 TPRINTF("Threads left: %" PRIua "\n", atomic_get(&thread_count));
     134                TPRINTF("Threads left: %" PRIua "\n",
     135                    atomic_get(&thread_count));
    125136                thread_sleep(1);
    126137        }
  • kernel/test/mm/slab1.c

    r2616a75b r380553c  
    155155       
    156156        semaphore_initialize(&thr_sem, 0);
    157         for (i = 0; i < THREADS; i++) { 
    158                 if (!(t = thread_create(slabtest, (void *) (sysarg_t) i, TASK, 0, "slabtest", false))) {
     157        for (i = 0; i < THREADS; i++) {
     158                if (!(t = thread_create(slabtest, (void *) (sysarg_t) i, TASK, THREAD_FLAG_NONE, "slabtest"))) {
    159159                        TPRINTF("Could not create thread %d\n", i);
    160160                } else
  • kernel/test/mm/slab2.c

    r2616a75b r380553c  
    5252        void *olddata1 = NULL, *olddata2 = NULL;
    5353       
    54         cache1 = slab_cache_create("cache1_tst", ITEM_SIZE, 0, NULL, NULL, 0);
    55         cache2 = slab_cache_create("cache2_tst", ITEM_SIZE, 0, NULL, NULL, 0);
     54        cache1 = slab_cache_create("test_cache1", ITEM_SIZE, 0, NULL, NULL, 0);
     55        cache2 = slab_cache_create("test_cache2", ITEM_SIZE, 0, NULL, NULL, 0);
    5656       
    5757        TPRINTF("Allocating...");
     
    210210        thr_cache = slab_cache_create("thread_cache", size, 0, NULL, NULL, 0);
    211211        semaphore_initialize(&thr_sem,0);
    212         for (i = 0; i < THREADS; i++) { 
    213                 if (!(t = thread_create(slabtest, NULL, TASK, 0, "slabtest", false))) {
     212        for (i = 0; i < THREADS; i++) {
     213                if (!(t = thread_create(slabtest, NULL, TASK, THREAD_FLAG_NONE, "slabtest"))) {
    214214                        TPRINTF("Could not create thread %d\n", i);
    215215                } else
  • kernel/test/synch/semaphore1.c

    r2616a75b r380553c  
    9393                for (j = 0; j < (CONSUMERS + PRODUCERS) / 2; j++) {
    9494                        for (k = 0; k < i; k++) {
    95                                 thrd = thread_create(consumer, NULL, TASK, 0, "consumer", false);
     95                                thrd = thread_create(consumer, NULL, TASK,
     96                                    THREAD_FLAG_NONE, "consumer");
    9697                                if (thrd)
    9798                                        thread_ready(thrd);
     
    100101                        }
    101102                        for (k = 0; k < (4 - i); k++) {
    102                                 thrd = thread_create(producer, NULL, TASK, 0, "producer", false);
     103                                thrd = thread_create(producer, NULL, TASK,
     104                                    THREAD_FLAG_NONE, "producer");
    103105                                if (thrd)
    104106                                        thread_ready(thrd);
  • kernel/test/synch/semaphore2.c

    r2616a75b r380553c  
    9393        TPRINTF("Creating %" PRIu32 " consumers\n", k);
    9494        for (i = 0; i < k; i++) {
    95                 thrd = thread_create(consumer, NULL, TASK, 0, "consumer", false);
     95                thrd = thread_create(consumer, NULL, TASK,
     96                    THREAD_FLAG_NONE, "consumer");
    9697                if (thrd)
    9798                        thread_ready(thrd);
  • kernel/test/thread/thread1.c

    r2616a75b r380553c  
    6363        for (i = 0; i < THREADS; i++) {
    6464                thread_t *t;
    65                 if (!(t = thread_create(threadtest, NULL, TASK, 0, "threadtest", false))) {
     65                if (!(t = thread_create(threadtest, NULL, TASK,
     66                    THREAD_FLAG_NONE, "threadtest"))) {
    6667                        TPRINTF("Could not create thread %d\n", i);
    6768                        break;
  • tools/toolchain.sh

    r2616a75b r380553c  
    5555BINUTILS_VERSION="2.22"
    5656BINUTILS_RELEASE=""
    57 GCC_VERSION="4.7.0"
     57GCC_VERSION="4.7.1"
    5858GDB_VERSION="7.4"
    5959
     
    274274       
    275275        download_fetch "${BINUTILS_SOURCE}" "${BINUTILS}" "ee0f10756c84979622b992a4a61ea3f5"
    276         download_fetch "${GCC_SOURCE}" "${GCC}" "2a0f1d99fda235c29d40b561f81d9a77"
     276        download_fetch "${GCC_SOURCE}" "${GCC}" "933e6f15f51c031060af64a9e14149ff"
    277277        download_fetch "${GDB_SOURCE}" "${GDB}" "95a9a8305fed4d30a30a6dc28ff9d060"
    278278}
Note: See TracChangeset for help on using the changeset viewer.