Changeset 6f4495f5 in mainline


Ignore:
Timestamp:
2007-01-27T17:32:13Z (18 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
1ba41c5
Parents:
51baa8a
Message:

Indentaion and formatting changes even Martin will like :-)

Location:
kernel
Files:
14 edited

Legend:

Unmodified
Added
Removed
  • kernel/arch/amd64/src/mm/memory_init.c

    r51baa8a r6f4495f5  
    4444size_t get_memory_size(void)
    4545{
    46         return e801memorysize*1024;
     46        return e801memorysize * 1024;
    4747}
    4848
     
    5151        uint8_t i;
    5252       
    53         for (i=0;i<e820counter;i++) {
     53        for (i = 0; i < e820counter; i++) {
    5454                printf("E820 base: %#llx size: %#llx type: ", e820table[i].base_address, e820table[i].size);
    5555                switch (e820table[i].type) {
    56                         case MEMMAP_MEMORY_AVAILABLE:
    57                                 printf("available memory\n");
    58                                 break;
    59                         case MEMMAP_MEMORY_RESERVED:
    60                                 printf("reserved memory\n");
    61                                 break;
    62                         case MEMMAP_MEMORY_ACPI:
    63                                 printf("ACPI table\n");
    64                                 break;
    65                         case MEMMAP_MEMORY_NVS:
    66                                 printf("NVS\n");
    67                                 break;
    68                         case MEMMAP_MEMORY_UNUSABLE:
    69                                 printf("unusable memory\n");
    70                                 break;
    71                         default:
    72                                 printf("undefined memory type\n");
     56                case MEMMAP_MEMORY_AVAILABLE:
     57                        printf("available memory\n");
     58                        break;
     59                case MEMMAP_MEMORY_RESERVED:
     60                        printf("reserved memory\n");
     61                        break;
     62                case MEMMAP_MEMORY_ACPI:
     63                        printf("ACPI table\n");
     64                        break;
     65                case MEMMAP_MEMORY_NVS:
     66                        printf("NVS\n");
     67                        break;
     68                case MEMMAP_MEMORY_UNUSABLE:
     69                        printf("unusable memory\n");
     70                        break;
     71                default:
     72                        printf("undefined memory type\n");
    7373                }
    7474        }
  • kernel/arch/ia32/src/mm/frame.c

    r51baa8a r6f4495f5  
    6666                        size = SIZE2FRAMES(ALIGN_DOWN(e820table[i].size,
    6767                                                   FRAME_SIZE));
    68                         if (minconf < start || minconf >= start+size)
     68                        if (minconf < start || minconf >= start + size)
    6969                                conf = start;
    7070                        else
  • kernel/arch/ia32/src/mm/memory_init.c

    r51baa8a r6f4495f5  
    4444size_t get_memory_size(void)
    4545{
    46         return e801memorysize*1024;
     46        return e801memorysize * 1024;
    4747}
    4848
     
    5151        uint8_t i;
    5252       
    53         for (i=0;i<e820counter;i++) {
     53        for (i = 0; i < e820counter; i++) {
    5454                printf("E820 base: %#.16llx size: %#.16llx type: ", e820table[i].base_address, e820table[i].size);
    5555                switch (e820table[i].type) {
    56                         case MEMMAP_MEMORY_AVAILABLE:
    57                                 printf("available memory\n");
    58                                 break;
    59                         case MEMMAP_MEMORY_RESERVED:
    60                                 printf("reserved memory\n");
    61                                 break;
    62                         case MEMMAP_MEMORY_ACPI:
    63                                 printf("ACPI table\n");
    64                                 break;
    65                         case MEMMAP_MEMORY_NVS:
    66                                 printf("NVS\n");
    67                                 break;
    68                         case MEMMAP_MEMORY_UNUSABLE:
    69                                 printf("unusable memory\n");
    70                                 break;
    71                         default:
    72                                 printf("undefined memory type\n");
     56                case MEMMAP_MEMORY_AVAILABLE:
     57                        printf("available memory\n");
     58                        break;
     59                case MEMMAP_MEMORY_RESERVED:
     60                        printf("reserved memory\n");
     61                        break;
     62                case MEMMAP_MEMORY_ACPI:
     63                        printf("ACPI table\n");
     64                        break;
     65                case MEMMAP_MEMORY_NVS:
     66                        printf("NVS\n");
     67                        break;
     68                case MEMMAP_MEMORY_UNUSABLE:
     69                        printf("unusable memory\n");
     70                        break;
     71                default:
     72                        printf("undefined memory type\n");
    7373                }
    7474        }
  • kernel/generic/src/main/kinit.c

    r51baa8a r6f4495f5  
    9999                 * Just a beautification.
    100100                 */
    101                 if ((t = thread_create(kmp, NULL, TASK, THREAD_FLAG_WIRED, "kmp", true))) {
     101                if ((t = thread_create(kmp, NULL, TASK, THREAD_FLAG_WIRED,
     102                    "kmp", true))) {
    102103                        spinlock_lock(&t->lock);
    103104                        t->cpu = &cpus[0];
     
    124125                for (i = 0; i < config.cpu_count; i++) {
    125126
    126                         if ((t = thread_create(kcpulb, NULL, TASK, THREAD_FLAG_WIRED, "kcpulb", true))) {
     127                        if ((t = thread_create(kcpulb, NULL, TASK,
     128                            THREAD_FLAG_WIRED, "kcpulb", true))) {
    127129                                spinlock_lock(&t->lock);                       
    128130                                t->cpu = &cpus[i];
     
    144146         * Create kernel console.
    145147         */
    146         if ((t = thread_create(kconsole, "kconsole", TASK, 0, "kconsole", false)))
     148        t = thread_create(kconsole, "kconsole", TASK, 0, "kconsole", false);
     149        if (t)
    147150                thread_ready(t);
    148151        else
     
    162165                }
    163166
    164                 task_t *utask = task_run_program((void *) init.tasks[i].addr, "uspace");
     167                task_t *utask = task_run_program((void *) init.tasks[i].addr,
     168                    "uspace");
    165169                if (utask) {
    166170                        /*
    167171                         * Set capabilities to init userspace tasks.
    168172                         */
    169                         cap_set(utask, CAP_CAP | CAP_MEM_MANAGER | CAP_IO_MANAGER | CAP_PREEMPT_CONTROL | CAP_IRQ_REG);
     173                        cap_set(utask, CAP_CAP | CAP_MEM_MANAGER |
     174                            CAP_IO_MANAGER | CAP_PREEMPT_CONTROL | CAP_IRQ_REG);
    170175                       
    171176                        if (!ipc_phone_0)
    172177                                ipc_phone_0 = &utask->answerbox;
    173178                } else {
    174                         int rd = init_rd((rd_header *) init.tasks[i].addr, init.tasks[i].size);
     179                        int rd = init_rd((rd_header *) init.tasks[i].addr,
     180                            init.tasks[i].size);
    175181                       
    176182                        if (rd != RE_OK)
  • kernel/generic/src/main/main.c

    r51baa8a r6f4495f5  
    147147       
    148148        config.kernel_size = ALIGN_UP(hardcoded_ktext_size +
    149                 hardcoded_kdata_size, PAGE_SIZE);
     149            hardcoded_kdata_size, PAGE_SIZE);
    150150        config.stack_size = CONFIG_STACK_SIZE;
    151151       
     
    157157        for (i = 0; i < init.cnt; i++) {
    158158                if (PA_overlaps(config.stack_base, config.stack_size,
    159                         init.tasks[i].addr, init.tasks[i].size))
     159                    init.tasks[i].addr, init.tasks[i].size))
    160160                        config.stack_base = ALIGN_UP(init.tasks[i].addr +
    161                                 init.tasks[i].size, config.stack_size);
     161                            init.tasks[i].size, config.stack_size);
    162162        }
    163163
     
    165165        if (ballocs.size) {
    166166                if (PA_overlaps(config.stack_base, config.stack_size,
    167                         ballocs.base, ballocs.size))
     167                    ballocs.base, ballocs.size))
    168168                        config.stack_base = ALIGN_UP(ballocs.base +
    169                                 ballocs.size, PAGE_SIZE);
     169                            ballocs.size, PAGE_SIZE);
    170170        }
    171171       
     
    175175        context_save(&ctx);
    176176        context_set(&ctx, FADDR(main_bsp_separated_stack), config.stack_base,
    177                 THREAD_STACK_SIZE);
     177            THREAD_STACK_SIZE);
    178178        context_restore(&ctx);
    179179        /* not reached */
     
    223223        version_print();
    224224        printf("kernel: %.*p hardcoded_ktext_size=%zdK, "
    225                 "hardcoded_kdata_size=%zdK\n", sizeof(uintptr_t) * 2,
    226                 config.base, hardcoded_ktext_size >> 10, hardcoded_kdata_size >>
    227                 10);
     225            "hardcoded_kdata_size=%zdK\n", sizeof(uintptr_t) * 2,
     226            config.base, hardcoded_ktext_size >> 10,
     227            hardcoded_kdata_size >> 10);
    228228        printf("stack:  %.*p size=%zdK\n", sizeof(uintptr_t) * 2,
    229                 config.stack_base, config.stack_size >> 10);
     229            config.stack_base, config.stack_size >> 10);
    230230
    231231        arch_pre_smp_init();
     
    250250                for (i = 0; i < init.cnt; i++)
    251251                        printf("init[%zd].addr=%.*p, init[%zd].size=%zd\n", i,
    252                                 sizeof(uintptr_t) * 2, init.tasks[i].addr, i,
    253                                 init.tasks[i].size);
     252                            sizeof(uintptr_t) * 2, init.tasks[i].addr, i,
     253                            init.tasks[i].size);
    254254        } else
    255255                printf("No init binaries found\n");
     
    324324         */
    325325        context_set(&CPU->saved_context, FADDR(main_ap_separated_stack),
    326                 (uintptr_t) CPU->stack, CPU_STACK_SIZE);
     326            (uintptr_t) CPU->stack, CPU_STACK_SIZE);
    327327        context_restore(&CPU->saved_context);
    328328        /* not reached */
  • kernel/generic/src/main/uinit.c

    r51baa8a r6f4495f5  
    4949/** Thread used to bring up userspace thread.
    5050 *
    51  * @param arg Pointer to structure containing userspace entry and stack addresses.
     51 * @param arg Pointer to structure containing userspace entry and stack
     52 *     addresses.
    5253 */
    5354void uinit(void *arg)
  • kernel/generic/src/mm/as.c

    r51baa8a r6f4495f5  
    9494static slab_cache_t *as_slab;
    9595
    96 /** This lock protects inactive_as_with_asid_head list. It must be acquired before as_t mutex. */
     96/**
     97 * This lock protects inactive_as_with_asid_head list. It must be acquired
     98 * before as_t mutex.
     99 */
    97100SPINLOCK_INITIALIZE(inactive_as_with_asid_lock);
    98101
     
    108111static int area_flags_to_page_flags(int aflags);
    109112static as_area_t *find_area_and_lock(as_t *as, uintptr_t va);
    110 static bool check_area_conflicts(as_t *as, uintptr_t va, size_t size, as_area_t *avoid_area);
     113static bool check_area_conflicts(as_t *as, uintptr_t va, size_t size,
     114    as_area_t *avoid_area);
    111115static void sh_info_remove_reference(share_info_t *sh_info);
    112116
     
    137141       
    138142        as_slab = slab_cache_create("as_slab", sizeof(as_t), 0,
    139                 as_constructor, as_destructor, SLAB_CACHE_MAGDEFERRED);
     143            as_constructor, as_destructor, SLAB_CACHE_MAGDEFERRED);
    140144       
    141145        AS_KERNEL = as_create(FLAG_AS_KERNEL);
     
    172176/** Destroy adress space.
    173177 *
    174  * When there are no tasks referencing this address space (i.e. its refcount is zero),
    175  * the address space can be destroyed.
     178 * When there are no tasks referencing this address space (i.e. its refcount is
     179 * zero), the address space can be destroyed.
    176180 */
    177181void as_destroy(as_t *as)
     
    204208
    205209                ASSERT(!list_empty(&as->as_area_btree.leaf_head));
    206                 node = list_get_instance(as->as_area_btree.leaf_head.next, btree_node_t, leaf_link);
     210                node = list_get_instance(as->as_area_btree.leaf_head.next,
     211                    btree_node_t, leaf_link);
    207212
    208213                if ((cond = node->keys)) {
     
    273278                a->backend_data = *backend_data;
    274279        else
    275                 memsetb((uintptr_t) &a->backend_data, sizeof(a->backend_data), 0);
     280                memsetb((uintptr_t) &a->backend_data, sizeof(a->backend_data),
     281                    0);
    276282
    277283        btree_create(&a->used_space);
     
    288294 *
    289295 * @param as Address space.
    290  * @param address Virtual address belonging to the area to be changed. Must be page-aligned.
     296 * @param address Virtual address belonging to the area to be changed. Must be
     297 *     page-aligned.
    291298 * @param size New size of the virtual memory block starting at address.
    292299 * @param flags Flags influencing the remap operation. Currently unused.
     
    357364                 * Start TLB shootdown sequence.
    358365                 */
    359                 tlb_shootdown_start(TLB_INVL_PAGES, AS->asid, area->base + pages*PAGE_SIZE, area->pages - pages);
     366                tlb_shootdown_start(TLB_INVL_PAGES, AS->asid, area->base +
     367                    pages * PAGE_SIZE, area->pages - pages);
    360368
    361369                /*
     
    370378               
    371379                        ASSERT(!list_empty(&area->used_space.leaf_head));
    372                         node = list_get_instance(area->used_space.leaf_head.prev, btree_node_t, leaf_link);
     380                        node =
     381                            list_get_instance(area->used_space.leaf_head.prev,
     382                            btree_node_t, leaf_link);
    373383                        if ((cond = (bool) node->keys)) {
    374384                                uintptr_t b = node->key[node->keys - 1];
    375                                 count_t c = (count_t) node->value[node->keys - 1];
     385                                count_t c =
     386                                    (count_t) node->value[node->keys - 1];
    376387                                int i = 0;
    377388                       
    378                                 if (overlaps(b, c*PAGE_SIZE, area->base, pages*PAGE_SIZE)) {
     389                                if (overlaps(b, c * PAGE_SIZE, area->base,
     390                                    pages*PAGE_SIZE)) {
    379391                                       
    380                                         if (b + c*PAGE_SIZE <= start_free) {
     392                                        if (b + c * PAGE_SIZE <= start_free) {
    381393                                                /*
    382                                                  * The whole interval fits completely
    383                                                  * in the resized address space area.
     394                                                 * The whole interval fits
     395                                                 * completely in the resized
     396                                                 * address space area.
    384397                                                 */
    385398                                                break;
     
    387400               
    388401                                        /*
    389                                          * Part of the interval corresponding to b and c
    390                                          * overlaps with the resized address space area.
     402                                         * Part of the interval corresponding
     403                                         * to b and c overlaps with the resized
     404                                         * address space area.
    391405                                         */
    392406               
    393407                                        cond = false;   /* we are almost done */
    394408                                        i = (start_free - b) >> PAGE_WIDTH;
    395                                         if (!used_space_remove(area, start_free, c - i))
    396                                                 panic("Could not remove used space.\n");
     409                                        if (!used_space_remove(area, start_free,
     410                                            c - i))
     411                                                panic("Could not remove used "
     412                                                    "space.\n");
    397413                                } else {
    398414                                        /*
    399                                          * The interval of used space can be completely removed.
     415                                         * The interval of used space can be
     416                                         * completely removed.
    400417                                         */
    401418                                        if (!used_space_remove(area, b, c))
    402                                                 panic("Could not remove used space.\n");
     419                                                panic("Could not remove used "
     420                                                    "space.\n");
    403421                                }
    404422                       
     
    407425                       
    408426                                        page_table_lock(as, false);
    409                                         pte = page_mapping_find(as, b + i*PAGE_SIZE);
    410                                         ASSERT(pte && PTE_VALID(pte) && PTE_PRESENT(pte));
    411                                         if (area->backend && area->backend->frame_free) {
     427                                        pte = page_mapping_find(as, b +
     428                                            i * PAGE_SIZE);
     429                                        ASSERT(pte && PTE_VALID(pte) &&
     430                                            PTE_PRESENT(pte));
     431                                        if (area->backend &&
     432                                            area->backend->frame_free) {
    412433                                                area->backend->frame_free(area,
    413                                                         b + i*PAGE_SIZE, PTE_GET_FRAME(pte));
     434                                                    b + i * PAGE_SIZE,
     435                                                    PTE_GET_FRAME(pte));
    414436                                        }
    415                                         page_mapping_remove(as, b + i*PAGE_SIZE);
     437                                        page_mapping_remove(as, b +
     438                                            i * PAGE_SIZE);
    416439                                        page_table_unlock(as, false);
    417440                                }
     
    422445                 * Finish TLB shootdown sequence.
    423446                 */
    424                 tlb_invalidate_pages(as->asid, area->base + pages*PAGE_SIZE, area->pages - pages);
     447                tlb_invalidate_pages(as->asid, area->base + pages * PAGE_SIZE,
     448                    area->pages - pages);
    425449                tlb_shootdown_finalize();
    426450               
     
    428452                 * Invalidate software translation caches (e.g. TSB on sparc64).
    429453                 */
    430                 as_invalidate_translation_cache(as, area->base + pages*PAGE_SIZE, area->pages - pages);
     454                as_invalidate_translation_cache(as, area->base +
     455                    pages * PAGE_SIZE, area->pages - pages);
    431456        } else {
    432457                /*
     
    434459                 * Check for overlaps with other address space areas.
    435460                 */
    436                 if (!check_area_conflicts(as, address, pages * PAGE_SIZE, area)) {
     461                if (!check_area_conflicts(as, address, pages * PAGE_SIZE,
     462                    area)) {
    437463                        mutex_unlock(&area->lock);
    438464                        mutex_unlock(&as->lock);               
     
    485511         * Visit only the pages mapped by used_space B+tree.
    486512         */
    487         for (cur = area->used_space.leaf_head.next; cur != &area->used_space.leaf_head; cur = cur->next) {
     513        for (cur = area->used_space.leaf_head.next;
     514            cur != &area->used_space.leaf_head; cur = cur->next) {
    488515                btree_node_t *node;
    489516                int i;
     
    497524                        for (j = 0; j < (count_t) node->value[i]; j++) {
    498525                                page_table_lock(as, false);
    499                                 pte = page_mapping_find(as, b + j*PAGE_SIZE);
    500                                 ASSERT(pte && PTE_VALID(pte) && PTE_PRESENT(pte));
    501                                 if (area->backend && area->backend->frame_free) {
    502                                         area->backend->frame_free(area,
    503                                                 b + j*PAGE_SIZE, PTE_GET_FRAME(pte));
     526                                pte = page_mapping_find(as, b + j * PAGE_SIZE);
     527                                ASSERT(pte && PTE_VALID(pte) &&
     528                                    PTE_PRESENT(pte));
     529                                if (area->backend &&
     530                                    area->backend->frame_free) {
     531                                        area->backend->frame_free(area, b +
     532                                        j * PAGE_SIZE, PTE_GET_FRAME(pte));
    504533                                }
    505                                 page_mapping_remove(as, b + j*PAGE_SIZE);                               
     534                                page_mapping_remove(as, b + j * PAGE_SIZE);                             
    506535                                page_table_unlock(as, false);
    507536                        }
     
    516545       
    517546        /*
    518          * Invalidate potential software translation caches (e.g. TSB on sparc64).
     547         * Invalidate potential software translation caches (e.g. TSB on
     548         * sparc64).
    519549         */
    520550        as_invalidate_translation_cache(as, area->base, area->pages);
     
    606636                dst_flags_mask |= AS_AREA_CACHEABLE;
    607637
    608         if (src_size != acc_size || (src_flags & dst_flags_mask) != dst_flags_mask) {
     638        if (src_size != acc_size ||
     639            (src_flags & dst_flags_mask) != dst_flags_mask) {
    609640                mutex_unlock(&src_area->lock);
    610641                mutex_unlock(&src_as->lock);
     
    659690         */
    660691        dst_area = as_area_create(dst_as, dst_flags_mask, src_size, dst_base,
    661                                   AS_AREA_ATTR_PARTIAL, src_backend, &src_backend_data);
     692            AS_AREA_ATTR_PARTIAL, src_backend, &src_backend_data);
    662693        if (!dst_area) {
    663694                /*
     
    777808                if (PTE_PRESENT(pte)) {
    778809                        if (((access == PF_ACCESS_READ) && PTE_READABLE(pte)) ||
    779                                 (access == PF_ACCESS_WRITE && PTE_WRITABLE(pte)) ||
    780                                 (access == PF_ACCESS_EXEC && PTE_EXECUTABLE(pte))) {
     810                            (access == PF_ACCESS_WRITE && PTE_WRITABLE(pte)) ||
     811                            (access == PF_ACCESS_EXEC && PTE_EXECUTABLE(pte))) {
    781812                                page_table_unlock(AS, false);
    782813                                mutex_unlock(&area->lock);
     
    805836        if (THREAD->in_copy_from_uspace) {
    806837                THREAD->in_copy_from_uspace = false;
    807                 istate_set_retaddr(istate, (uintptr_t) &memcpy_from_uspace_failover_address);
     838                istate_set_retaddr(istate,
     839                    (uintptr_t) &memcpy_from_uspace_failover_address);
    808840        } else if (THREAD->in_copy_to_uspace) {
    809841                THREAD->in_copy_to_uspace = false;
    810                 istate_set_retaddr(istate, (uintptr_t) &memcpy_to_uspace_failover_address);
     842                istate_set_retaddr(istate,
     843                    (uintptr_t) &memcpy_to_uspace_failover_address);
    811844        } else {
    812845                return AS_PF_FAULT;
     
    846879                         */
    847880                         ASSERT(old->asid != ASID_INVALID);
    848                          list_append(&old->inactive_as_with_asid_link, &inactive_as_with_asid_head);
     881                         list_append(&old->inactive_as_with_asid_link,
     882                             &inactive_as_with_asid_head);
    849883                }
    850884                mutex_unlock(&old->lock);
     
    862896        mutex_lock_active(&new->lock);
    863897        if ((new->cpu_refcount++ == 0) && (new != AS_KERNEL)) {
    864                 if (new->asid != ASID_INVALID)
     898                if (new->asid != ASID_INVALID) {
    865899                        list_remove(&new->inactive_as_with_asid_link);
    866                 else
    867                         needs_asid = true;      /* defer call to asid_get() until new->lock is released */
     900                } else {
     901                        /*
     902                         * Defer call to asid_get() until new->lock is released.
     903                         */
     904                        needs_asid = true;
     905                }
    868906        }
    869907        SET_PTL0_ADDRESS(new->page_table);
     
    10071045 * @param va Virtual address.
    10081046 *
    1009  * @return Locked address space area containing va on success or NULL on failure.
     1047 * @return Locked address space area containing va on success or NULL on
     1048 *     failure.
    10101049 */
    10111050as_area_t *find_area_and_lock(as_t *as, uintptr_t va)
     
    10421081         * Because of its position in the B+tree, it must have base < va.
    10431082         */
    1044         if ((lnode = btree_leaf_node_left_neighbour(&as->as_area_btree, leaf))) {
     1083        lnode = btree_leaf_node_left_neighbour(&as->as_area_btree, leaf);
     1084        if (lnode) {
    10451085                a = (as_area_t *) lnode->value[lnode->keys - 1];
    10461086                mutex_lock(&a->lock);
     
    10651105 * @return True if there is no conflict, false otherwise.
    10661106 */
    1067 bool check_area_conflicts(as_t *as, uintptr_t va, size_t size, as_area_t *avoid_area)
     1107bool check_area_conflicts(as_t *as, uintptr_t va, size_t size,
     1108                          as_area_t *avoid_area)
    10681109{
    10691110        as_area_t *a;
     
    11001141                mutex_unlock(&a->lock);
    11011142        }
    1102         if ((node = btree_leaf_node_right_neighbour(&as->as_area_btree, leaf))) {
     1143        node = btree_leaf_node_right_neighbour(&as->as_area_btree, leaf);
     1144        if (node) {
    11031145                a = (as_area_t *) node->value[0];
    11041146                mutex_lock(&a->lock);
     
    11311173        if (!KERNEL_ADDRESS_SPACE_SHADOWED) {
    11321174                return !overlaps(va, size,
    1133                         KERNEL_ADDRESS_SPACE_START, KERNEL_ADDRESS_SPACE_END-KERNEL_ADDRESS_SPACE_START);
     1175                    KERNEL_ADDRESS_SPACE_START,
     1176                    KERNEL_ADDRESS_SPACE_END - KERNEL_ADDRESS_SPACE_START);
    11341177        }
    11351178
     
    11901233        node = btree_leaf_node_left_neighbour(&a->used_space, leaf);
    11911234        if (node) {
    1192                 uintptr_t left_pg = node->key[node->keys - 1], right_pg = leaf->key[0];
    1193                 count_t left_cnt = (count_t) node->value[node->keys - 1], right_cnt = (count_t) leaf->value[0];
     1235                uintptr_t left_pg = node->key[node->keys - 1];
     1236                uintptr_t right_pg = leaf->key[0];
     1237                count_t left_cnt = (count_t) node->value[node->keys - 1];
     1238                count_t right_cnt = (count_t) leaf->value[0];
    11941239               
    11951240                /*
     
    12011246                if (page >= right_pg) {
    12021247                        /* Do nothing. */
    1203                 } else if (overlaps(page, count*PAGE_SIZE, left_pg, left_cnt*PAGE_SIZE)) {
     1248                } else if (overlaps(page, count * PAGE_SIZE, left_pg,
     1249                    left_cnt * PAGE_SIZE)) {
    12041250                        /* The interval intersects with the left interval. */
    12051251                        return 0;
    1206                 } else if (overlaps(page, count*PAGE_SIZE, right_pg, right_cnt*PAGE_SIZE)) {
     1252                } else if (overlaps(page, count * PAGE_SIZE, right_pg,
     1253                    right_cnt * PAGE_SIZE)) {
    12071254                        /* The interval intersects with the right interval. */
    12081255                        return 0;                       
    1209                 } else if ((page == left_pg + left_cnt*PAGE_SIZE) && (page + count*PAGE_SIZE == right_pg)) {
    1210                         /* The interval can be added by merging the two already present intervals. */
     1256                } else if ((page == left_pg + left_cnt * PAGE_SIZE) &&
     1257                    (page + count * PAGE_SIZE == right_pg)) {
     1258                        /*
     1259                         * The interval can be added by merging the two already
     1260                         * present intervals.
     1261                         */
    12111262                        node->value[node->keys - 1] += count + right_cnt;
    12121263                        btree_remove(&a->used_space, right_pg, leaf);
    12131264                        return 1;
    1214                 } else if (page == left_pg + left_cnt*PAGE_SIZE) {
    1215                         /* The interval can be added by simply growing the left interval. */
     1265                } else if (page == left_pg + left_cnt * PAGE_SIZE) {
     1266                        /*
     1267                         * The interval can be added by simply growing the left
     1268                         * interval.
     1269                         */
    12161270                        node->value[node->keys - 1] += count;
    12171271                        return 1;
    1218                 } else if (page + count*PAGE_SIZE == right_pg) {
     1272                } else if (page + count * PAGE_SIZE == right_pg) {
    12191273                        /*
    1220                          * The interval can be addded by simply moving base of the right
    1221                          * interval down and increasing its size accordingly.
     1274                         * The interval can be addded by simply moving base of
     1275                         * the right interval down and increasing its size
     1276                         * accordingly.
    12221277                         */
    12231278                        leaf->value[0] += count;
     
    12291284                         * but cannot be merged with any of them.
    12301285                         */
    1231                         btree_insert(&a->used_space, page, (void *) count, leaf);
     1286                        btree_insert(&a->used_space, page, (void *) count,
     1287                            leaf);
    12321288                        return 1;
    12331289                }
     
    12371293       
    12381294                /*
    1239                  * Investigate the border case in which the left neighbour does not
    1240                  * exist but the interval fits from the left.
     1295                 * Investigate the border case in which the left neighbour does
     1296                 * not exist but the interval fits from the left.
    12411297                 */
    12421298                 
    1243                 if (overlaps(page, count*PAGE_SIZE, right_pg, right_cnt*PAGE_SIZE)) {
     1299                if (overlaps(page, count * PAGE_SIZE, right_pg,
     1300                    right_cnt * PAGE_SIZE)) {
    12441301                        /* The interval intersects with the right interval. */
    12451302                        return 0;
    1246                 } else if (page + count*PAGE_SIZE == right_pg) {
     1303                } else if (page + count * PAGE_SIZE == right_pg) {
    12471304                        /*
    1248                          * The interval can be added by moving the base of the right interval down
    1249                          * and increasing its size accordingly.
     1305                         * The interval can be added by moving the base of the
     1306                         * right interval down and increasing its size
     1307                         * accordingly.
    12501308                         */
    12511309                        leaf->key[0] = page;
     
    12571315                         * It must be added individually.
    12581316                         */
    1259                         btree_insert(&a->used_space, page, (void *) count, leaf);
     1317                        btree_insert(&a->used_space, page, (void *) count,
     1318                            leaf);
    12601319                        return 1;
    12611320                }
     
    12641323        node = btree_leaf_node_right_neighbour(&a->used_space, leaf);
    12651324        if (node) {
    1266                 uintptr_t left_pg = leaf->key[leaf->keys - 1], right_pg = node->key[0];
    1267                 count_t left_cnt = (count_t) leaf->value[leaf->keys - 1], right_cnt = (count_t) node->value[0];
     1325                uintptr_t left_pg = leaf->key[leaf->keys - 1];
     1326                uintptr_t right_pg = node->key[0];
     1327                count_t left_cnt = (count_t) leaf->value[leaf->keys - 1];
     1328                count_t right_cnt = (count_t) node->value[0];
    12681329               
    12691330                /*
     
    12751336                if (page < left_pg) {
    12761337                        /* Do nothing. */
    1277                 } else if (overlaps(page, count*PAGE_SIZE, left_pg, left_cnt*PAGE_SIZE)) {
     1338                } else if (overlaps(page, count * PAGE_SIZE, left_pg,
     1339                    left_cnt * PAGE_SIZE)) {
    12781340                        /* The interval intersects with the left interval. */
    12791341                        return 0;
    1280                 } else if (overlaps(page, count*PAGE_SIZE, right_pg, right_cnt*PAGE_SIZE)) {
     1342                } else if (overlaps(page, count * PAGE_SIZE, right_pg,
     1343                    right_cnt * PAGE_SIZE)) {
    12811344                        /* The interval intersects with the right interval. */
    12821345                        return 0;                       
    1283                 } else if ((page == left_pg + left_cnt*PAGE_SIZE) && (page + count*PAGE_SIZE == right_pg)) {
    1284                         /* The interval can be added by merging the two already present intervals. */
     1346                } else if ((page == left_pg + left_cnt * PAGE_SIZE) &&
     1347                    (page + count * PAGE_SIZE == right_pg)) {
     1348                        /*
     1349                         * The interval can be added by merging the two already
     1350                         * present intervals.
     1351                         * */
    12851352                        leaf->value[leaf->keys - 1] += count + right_cnt;
    12861353                        btree_remove(&a->used_space, right_pg, node);
    12871354                        return 1;
    1288                 } else if (page == left_pg + left_cnt*PAGE_SIZE) {
    1289                         /* The interval can be added by simply growing the left interval. */
     1355                } else if (page == left_pg + left_cnt * PAGE_SIZE) {
     1356                        /*
     1357                         * The interval can be added by simply growing the left
     1358                         * interval.
     1359                         * */
    12901360                        leaf->value[leaf->keys - 1] +=  count;
    12911361                        return 1;
    1292                 } else if (page + count*PAGE_SIZE == right_pg) {
     1362                } else if (page + count * PAGE_SIZE == right_pg) {
    12931363                        /*
    1294                          * The interval can be addded by simply moving base of the right
    1295                          * interval down and increasing its size accordingly.
     1364                         * The interval can be addded by simply moving base of
     1365                         * the right interval down and increasing its size
     1366                         * accordingly.
    12961367                         */
    12971368                        node->value[0] += count;
     
    13031374                         * but cannot be merged with any of them.
    13041375                         */
    1305                         btree_insert(&a->used_space, page, (void *) count, leaf);
     1376                        btree_insert(&a->used_space, page, (void *) count,
     1377                            leaf);
    13061378                        return 1;
    13071379                }
     
    13111383       
    13121384                /*
    1313                  * Investigate the border case in which the right neighbour does not
    1314                  * exist but the interval fits from the right.
     1385                 * Investigate the border case in which the right neighbour
     1386                 * does not exist but the interval fits from the right.
    13151387                 */
    13161388                 
    1317                 if (overlaps(page, count*PAGE_SIZE, left_pg, left_cnt*PAGE_SIZE)) {
     1389                if (overlaps(page, count * PAGE_SIZE, left_pg,
     1390                    left_cnt * PAGE_SIZE)) {
    13181391                        /* The interval intersects with the left interval. */
    13191392                        return 0;
    1320                 } else if (left_pg + left_cnt*PAGE_SIZE == page) {
    1321                         /* The interval can be added by growing the left interval. */
     1393                } else if (left_pg + left_cnt * PAGE_SIZE == page) {
     1394                        /*
     1395                         * The interval can be added by growing the left
     1396                         * interval.
     1397                         */
    13221398                        leaf->value[leaf->keys - 1] += count;
    13231399                        return 1;
     
    13271403                         * It must be added individually.
    13281404                         */
    1329                         btree_insert(&a->used_space, page, (void *) count, leaf);
     1405                        btree_insert(&a->used_space, page, (void *) count,
     1406                            leaf);
    13301407                        return 1;
    13311408                }
     
    13331410       
    13341411        /*
    1335          * Note that if the algorithm made it thus far, the interval can fit only
    1336          * between two other intervals of the leaf. The two border cases were already
    1337          * resolved.
     1412         * Note that if the algorithm made it thus far, the interval can fit
     1413         * only between two other intervals of the leaf. The two border cases
     1414         * were already resolved.
    13381415         */
    13391416        for (i = 1; i < leaf->keys; i++) {
    13401417                if (page < leaf->key[i]) {
    1341                         uintptr_t left_pg = leaf->key[i - 1], right_pg = leaf->key[i];
    1342                         count_t left_cnt = (count_t) leaf->value[i - 1], right_cnt = (count_t) leaf->value[i];
     1418                        uintptr_t left_pg = leaf->key[i - 1];
     1419                        uintptr_t right_pg = leaf->key[i];
     1420                        count_t left_cnt = (count_t) leaf->value[i - 1];
     1421                        count_t right_cnt = (count_t) leaf->value[i];
    13431422
    13441423                        /*
     
    13461425                         */
    13471426
    1348                         if (overlaps(page, count*PAGE_SIZE, left_pg, left_cnt*PAGE_SIZE)) {
    1349                                 /* The interval intersects with the left interval. */
     1427                        if (overlaps(page, count * PAGE_SIZE, left_pg,
     1428                            left_cnt * PAGE_SIZE)) {
     1429                                /*
     1430                                 * The interval intersects with the left
     1431                                 * interval.
     1432                                 */
    13501433                                return 0;
    1351                         } else if (overlaps(page, count*PAGE_SIZE, right_pg, right_cnt*PAGE_SIZE)) {
    1352                                 /* The interval intersects with the right interval. */
     1434                        } else if (overlaps(page, count * PAGE_SIZE, right_pg,
     1435                            right_cnt * PAGE_SIZE)) {
     1436                                /*
     1437                                 * The interval intersects with the right
     1438                                 * interval.
     1439                                 */
    13531440                                return 0;                       
    1354                         } else if ((page == left_pg + left_cnt*PAGE_SIZE) && (page + count*PAGE_SIZE == right_pg)) {
    1355                                 /* The interval can be added by merging the two already present intervals. */
     1441                        } else if ((page == left_pg + left_cnt * PAGE_SIZE) &&
     1442                            (page + count * PAGE_SIZE == right_pg)) {
     1443                                /*
     1444                                 * The interval can be added by merging the two
     1445                                 * already present intervals.
     1446                                 */
    13561447                                leaf->value[i - 1] += count + right_cnt;
    13571448                                btree_remove(&a->used_space, right_pg, leaf);
    13581449                                return 1;
    1359                         } else if (page == left_pg + left_cnt*PAGE_SIZE) {
    1360                                 /* The interval can be added by simply growing the left interval. */
     1450                        } else if (page == left_pg + left_cnt * PAGE_SIZE) {
     1451                                /*
     1452                                 * The interval can be added by simply growing
     1453                                 * the left interval.
     1454                                 */
    13611455                                leaf->value[i - 1] += count;
    13621456                                return 1;
    1363                         } else if (page + count*PAGE_SIZE == right_pg) {
     1457                        } else if (page + count * PAGE_SIZE == right_pg) {
    13641458                                /*
    1365                                  * The interval can be addded by simply moving base of the right
    1366                                  * interval down and increasing its size accordingly.
     1459                                 * The interval can be addded by simply moving
     1460                                 * base of the right interval down and
     1461                                 * increasing its size accordingly.
    13671462                                 */
    13681463                                leaf->value[i] += count;
     
    13711466                        } else {
    13721467                                /*
    1373                                  * The interval is between both neigbouring intervals,
    1374                                  * but cannot be merged with any of them.
     1468                                 * The interval is between both neigbouring
     1469                                 * intervals, but cannot be merged with any of
     1470                                 * them.
    13751471                                 */
    1376                                 btree_insert(&a->used_space, page, (void *) count, leaf);
     1472                                btree_insert(&a->used_space, page,
     1473                                    (void *) count, leaf);
    13771474                                return 1;
    13781475                        }
     
    13801477        }
    13811478
    1382         panic("Inconsistency detected while adding %d pages of used space at %p.\n", count, page);
     1479        panic("Inconsistency detected while adding %d pages of used space at "
     1480            "%p.\n", count, page);
    13831481}
    13841482
     
    14191517                        for (i = 0; i < leaf->keys; i++) {
    14201518                                if (leaf->key[i] == page) {
    1421                                         leaf->key[i] += count*PAGE_SIZE;
     1519                                        leaf->key[i] += count * PAGE_SIZE;
    14221520                                        leaf->value[i] -= count;
    14231521                                        return 1;
     
    14331531                count_t left_cnt = (count_t) node->value[node->keys - 1];
    14341532
    1435                 if (overlaps(left_pg, left_cnt*PAGE_SIZE, page, count*PAGE_SIZE)) {
    1436                         if (page + count*PAGE_SIZE == left_pg + left_cnt*PAGE_SIZE) {
     1533                if (overlaps(left_pg, left_cnt * PAGE_SIZE, page,
     1534                    count * PAGE_SIZE)) {
     1535                        if (page + count * PAGE_SIZE ==
     1536                            left_pg + left_cnt * PAGE_SIZE) {
    14371537                                /*
    1438                                  * The interval is contained in the rightmost interval
    1439                                  * of the left neighbour and can be removed by
    1440                                  * updating the size of the bigger interval.
     1538                                 * The interval is contained in the rightmost
     1539                                 * interval of the left neighbour and can be
     1540                                 * removed by updating the size of the bigger
     1541                                 * interval.
    14411542                                 */
    14421543                                node->value[node->keys - 1] -= count;
    14431544                                return 1;
    1444                         } else if (page + count*PAGE_SIZE < left_pg + left_cnt*PAGE_SIZE) {
     1545                        } else if (page + count * PAGE_SIZE <
     1546                            left_pg + left_cnt*PAGE_SIZE) {
    14451547                                count_t new_cnt;
    14461548                               
    14471549                                /*
    1448                                  * The interval is contained in the rightmost interval
    1449                                  * of the left neighbour but its removal requires
    1450                                  * both updating the size of the original interval and
    1451                                  * also inserting a new interval.
     1550                                 * The interval is contained in the rightmost
     1551                                 * interval of the left neighbour but its
     1552                                 * removal requires both updating the size of
     1553                                 * the original interval and also inserting a
     1554                                 * new interval.
    14521555                                 */
    1453                                 new_cnt = ((left_pg + left_cnt*PAGE_SIZE) - (page + count*PAGE_SIZE)) >> PAGE_WIDTH;
     1556                                new_cnt = ((left_pg + left_cnt * PAGE_SIZE) -
     1557                                    (page + count*PAGE_SIZE)) >> PAGE_WIDTH;
    14541558                                node->value[node->keys - 1] -= count + new_cnt;
    1455                                 btree_insert(&a->used_space, page + count*PAGE_SIZE, (void *) new_cnt, leaf);
     1559                                btree_insert(&a->used_space, page +
     1560                                    count * PAGE_SIZE, (void *) new_cnt, leaf);
    14561561                                return 1;
    14571562                        }
     
    14661571                count_t left_cnt = (count_t) leaf->value[leaf->keys - 1];
    14671572
    1468                 if (overlaps(left_pg, left_cnt*PAGE_SIZE, page, count*PAGE_SIZE)) {
    1469                         if (page + count*PAGE_SIZE == left_pg + left_cnt*PAGE_SIZE) {
     1573                if (overlaps(left_pg, left_cnt * PAGE_SIZE, page,
     1574                    count * PAGE_SIZE)) {
     1575                        if (page + count * PAGE_SIZE ==
     1576                            left_pg + left_cnt * PAGE_SIZE) {
    14701577                                /*
    1471                                  * The interval is contained in the rightmost interval
    1472                                  * of the leaf and can be removed by updating the size
    1473                                  * of the bigger interval.
     1578                                 * The interval is contained in the rightmost
     1579                                 * interval of the leaf and can be removed by
     1580                                 * updating the size of the bigger interval.
    14741581                                 */
    14751582                                leaf->value[leaf->keys - 1] -= count;
    14761583                                return 1;
    1477                         } else if (page + count*PAGE_SIZE < left_pg + left_cnt*PAGE_SIZE) {
     1584                        } else if (page + count * PAGE_SIZE < left_pg +
     1585                            left_cnt * PAGE_SIZE) {
    14781586                                count_t new_cnt;
    14791587                               
    14801588                                /*
    1481                                  * The interval is contained in the rightmost interval
    1482                                  * of the leaf but its removal requires both updating
    1483                                  * the size of the original interval and
    1484                                  * also inserting a new interval.
     1589                                 * The interval is contained in the rightmost
     1590                                 * interval of the leaf but its removal
     1591                                 * requires both updating the size of the
     1592                                 * original interval and also inserting a new
     1593                                 * interval.
    14851594                                 */
    1486                                 new_cnt = ((left_pg + left_cnt*PAGE_SIZE) - (page + count*PAGE_SIZE)) >> PAGE_WIDTH;
     1595                                new_cnt = ((left_pg + left_cnt * PAGE_SIZE) -
     1596                                    (page + count * PAGE_SIZE)) >> PAGE_WIDTH;
    14871597                                leaf->value[leaf->keys - 1] -= count + new_cnt;
    1488                                 btree_insert(&a->used_space, page + count*PAGE_SIZE, (void *) new_cnt, leaf);
     1598                                btree_insert(&a->used_space, page +
     1599                                    count * PAGE_SIZE, (void *) new_cnt, leaf);
    14891600                                return 1;
    14901601                        }
     
    15031614
    15041615                        /*
    1505                          * Now the interval is between intervals corresponding to (i - 1) and i.
     1616                         * Now the interval is between intervals corresponding
     1617                         * to (i - 1) and i.
    15061618                         */
    1507                         if (overlaps(left_pg, left_cnt*PAGE_SIZE, page, count*PAGE_SIZE)) {
    1508                                 if (page + count*PAGE_SIZE == left_pg + left_cnt*PAGE_SIZE) {
     1619                        if (overlaps(left_pg, left_cnt * PAGE_SIZE, page,
     1620                            count * PAGE_SIZE)) {
     1621                                if (page + count * PAGE_SIZE ==
     1622                                    left_pg + left_cnt*PAGE_SIZE) {
    15091623                                        /*
    1510                                         * The interval is contained in the interval (i - 1)
    1511                                          * of the leaf and can be removed by updating the size
    1512                                          * of the bigger interval.
     1624                                         * The interval is contained in the
     1625                                         * interval (i - 1) of the leaf and can
     1626                                         * be removed by updating the size of
     1627                                         * the bigger interval.
    15131628                                         */
    15141629                                        leaf->value[i - 1] -= count;
    15151630                                        return 1;
    1516                                 } else if (page + count*PAGE_SIZE < left_pg + left_cnt*PAGE_SIZE) {
     1631                                } else if (page + count * PAGE_SIZE <
     1632                                    left_pg + left_cnt * PAGE_SIZE) {
    15171633                                        count_t new_cnt;
    15181634                               
    15191635                                        /*
    1520                                          * The interval is contained in the interval (i - 1)
    1521                                          * of the leaf but its removal requires both updating
    1522                                          * the size of the original interval and
     1636                                         * The interval is contained in the
     1637                                         * interval (i - 1) of the leaf but its
     1638                                         * removal requires both updating the
     1639                                         * size of the original interval and
    15231640                                         * also inserting a new interval.
    15241641                                         */
    1525                                         new_cnt = ((left_pg + left_cnt*PAGE_SIZE) - (page + count*PAGE_SIZE)) >> PAGE_WIDTH;
     1642                                        new_cnt = ((left_pg +
     1643                                            left_cnt * PAGE_SIZE) -
     1644                                            (page + count * PAGE_SIZE)) >>
     1645                                            PAGE_WIDTH;
    15261646                                        leaf->value[i - 1] -= count + new_cnt;
    1527                                         btree_insert(&a->used_space, page + count*PAGE_SIZE, (void *) new_cnt, leaf);
     1647                                        btree_insert(&a->used_space, page +
     1648                                            count * PAGE_SIZE, (void *) new_cnt,
     1649                                            leaf);
    15281650                                        return 1;
    15291651                                }
     
    15341656
    15351657error:
    1536         panic("Inconsistency detected while removing %d pages of used space from %p.\n", count, page);
     1658        panic("Inconsistency detected while removing %d pages of used space "
     1659            "from %p.\n", count, page);
    15371660}
    15381661
     
    15571680                 * reference from all frames found there.
    15581681                 */
    1559                 for (cur = sh_info->pagemap.leaf_head.next; cur != &sh_info->pagemap.leaf_head; cur = cur->next) {
     1682                for (cur = sh_info->pagemap.leaf_head.next;
     1683                    cur != &sh_info->pagemap.leaf_head; cur = cur->next) {
    15601684                        btree_node_t *node;
    15611685                        int i;
     
    15821706unative_t sys_as_area_create(uintptr_t address, size_t size, int flags)
    15831707{
    1584         if (as_area_create(AS, flags | AS_AREA_CACHEABLE, size, address, AS_AREA_ATTR_NONE, &anon_backend, NULL))
     1708        if (as_area_create(AS, flags | AS_AREA_CACHEABLE, size, address,
     1709            AS_AREA_ATTR_NONE, &anon_backend, NULL))
    15851710                return (unative_t) address;
    15861711        else
     
    16131738        /* print out info about address space areas */
    16141739        link_t *cur;
    1615         for (cur = as->as_area_btree.leaf_head.next; cur != &as->as_area_btree.leaf_head; cur = cur->next) {
    1616                 btree_node_t *node = list_get_instance(cur, btree_node_t, leaf_link);
     1740        for (cur = as->as_area_btree.leaf_head.next;
     1741            cur != &as->as_area_btree.leaf_head; cur = cur->next) {
     1742                btree_node_t *node;
     1743               
     1744                node = list_get_instance(cur, btree_node_t, leaf_link);
    16171745               
    16181746                int i;
     
    16221750                        mutex_lock(&area->lock);
    16231751                        printf("as_area: %p, base=%p, pages=%d (%p - %p)\n",
    1624                                 area, area->base, area->pages, area->base, area->base + area->pages*PAGE_SIZE);
     1752                            area, area->base, area->pages, area->base,
     1753                            area->base + area->pages*PAGE_SIZE);
    16251754                        mutex_unlock(&area->lock);
    16261755                }
  • kernel/generic/src/proc/scheduler.c

    r51baa8a r6f4495f5  
    361361        context_save(&CPU->saved_context);
    362362        context_set(&CPU->saved_context, FADDR(scheduler_separated_stack),
    363                 (uintptr_t) CPU->stack, CPU_STACK_SIZE);
     363            (uintptr_t) CPU->stack, CPU_STACK_SIZE);
    364364        context_restore(&CPU->saved_context);
    365365        /* not reached */
     
    501501#ifdef SCHEDULER_VERBOSE
    502502        printf("cpu%d: tid %d (priority=%d, ticks=%lld, nrdy=%ld)\n",
    503                 CPU->id, THREAD->tid, THREAD->priority, THREAD->ticks,
    504                 atomic_get(&CPU->nrdy));
     503            CPU->id, THREAD->tid, THREAD->priority, THREAD->ticks,
     504            atomic_get(&CPU->nrdy));
    505505#endif 
    506506
     
    636636#ifdef KCPULB_VERBOSE
    637637                                printf("kcpulb%d: TID %d -> cpu%d, nrdy=%ld, "
    638                                         "avg=%nd\n", CPU->id, t->tid, CPU->id,
    639                                         atomic_get(&CPU->nrdy),
    640                                         atomic_get(&nrdy) / config.cpu_active);
     638                                    "avg=%nd\n", CPU->id, t->tid, CPU->id,
     639                                    atomic_get(&CPU->nrdy),
     640                                    atomic_get(&nrdy) / config.cpu_active);
    641641#endif
    642642                                t->flags |= THREAD_FLAG_STOLEN;
     
    704704                spinlock_lock(&cpus[cpu].lock);
    705705                printf("cpu%d: address=%p, nrdy=%ld, needs_relink=%ld\n",
    706                         cpus[cpu].id, &cpus[cpu], atomic_get(&cpus[cpu].nrdy),
    707                         cpus[cpu].needs_relink);
     706                    cpus[cpu].id, &cpus[cpu], atomic_get(&cpus[cpu].nrdy),
     707                    cpus[cpu].needs_relink);
    708708               
    709709                for (i = 0; i < RQ_COUNT; i++) {
     
    719719                                t = list_get_instance(cur, thread_t, rq_link);
    720720                                printf("%d(%s) ", t->tid,
    721                                         thread_states[t->state]);
     721                                    thread_states[t->state]);
    722722                        }
    723723                        printf("\n");
  • kernel/generic/src/proc/task.c

    r51baa8a r6f4495f5  
    6666/** B+tree of active tasks.
    6767 *
    68  * The task is guaranteed to exist after it was found in the tasks_btree as long as:
     68 * The task is guaranteed to exist after it was found in the tasks_btree as
     69 * long as:
    6970 * @li the tasks_lock is held,
    70  * @li the task's lock is held when task's lock is acquired before releasing tasks_lock or
     71 * @li the task's lock is held when task's lock is acquired before releasing
     72 *     tasks_lock or
    7173 * @li the task's refcount is greater than 0
    7274 *
     
    126128        for (i = 0; i < IPC_MAX_PHONES; i++)
    127129                ipc_phone_init(&ta->phones[i]);
    128         if ((ipc_phone_0) && (context_check(ipc_phone_0->task->context, ta->context)))
     130        if ((ipc_phone_0) && (context_check(ipc_phone_0->task->context,
     131            ta->context)))
    129132                ipc_phone_connect(&ta->phones[0], ipc_phone_0);
    130133        atomic_set(&ta->active_calls, 0);
     
    203206       
    204207        kernel_uarg = (uspace_arg_t *) malloc(sizeof(uspace_arg_t), 0);
    205         kernel_uarg->uspace_entry = (void *) ((elf_header_t *) program_addr)->e_entry;
     208        kernel_uarg->uspace_entry =
     209            (void *) ((elf_header_t *) program_addr)->e_entry;
    206210        kernel_uarg->uspace_stack = (void *) USTACK_ADDRESS;
    207211        kernel_uarg->uspace_thread_function = NULL;
     
    215219         * Create the data as_area.
    216220         */
    217         a = as_area_create(as, AS_AREA_READ | AS_AREA_WRITE | AS_AREA_CACHEABLE, 
    218                 LOADED_PROG_STACK_PAGES_NO*PAGE_SIZE,
    219                 USTACK_ADDRESS, AS_AREA_ATTR_NONE, &anon_backend, NULL);
     221        a = as_area_create(as, AS_AREA_READ | AS_AREA_WRITE | AS_AREA_CACHEABLE,
     222            LOADED_PROG_STACK_PAGES_NO * PAGE_SIZE, USTACK_ADDRESS,
     223            AS_AREA_ATTR_NONE, &anon_backend, NULL);
    220224
    221225        /*
    222226         * Create the main thread.
    223227         */
    224         t1 = thread_create(uinit, kernel_uarg, task, THREAD_FLAG_USPACE, "uinit", false);
     228        t1 = thread_create(uinit, kernel_uarg, task, THREAD_FLAG_USPACE,
     229            "uinit", false);
    225230        ASSERT(t1);
    226231       
     
    239244/** Syscall for reading task ID from userspace.
    240245 *
    241  * @param uspace_task_id Userspace address of 8-byte buffer where to store current task ID.
     246 * @param uspace_task_id Userspace address of 8-byte buffer where to store
     247 * current task ID.
    242248 *
    243249 * @return 0 on success or an error code from @ref errno.h.
     
    249255         * remains constant for the lifespan of the task.
    250256         */
    251         return (unative_t) copy_to_uspace(uspace_task_id, &TASK->taskid, sizeof(TASK->taskid));
     257        return (unative_t) copy_to_uspace(uspace_task_id, &TASK->taskid,
     258            sizeof(TASK->taskid));
    252259}
    253260
     
    289296                /* Process only counted threads */
    290297                if (!thr->uncounted) {
    291                         if (thr == THREAD) /* Update accounting of current thread */
    292                                 thread_update_accounting();
     298                        if (thr == THREAD) {
     299                                /* Update accounting of current thread */
     300                                thread_update_accounting();
     301                        }
    293302                        ret += thr->cycles;
    294303                }
     
    377386        spinlock_lock(&tasks_lock);
    378387       
    379         printf("taskid name       ctx address    as         cycles     threads calls  callee\n");
    380         printf("------ ---------- --- ---------- ---------- ---------- ------- ------ ------>\n");
    381 
    382         for (cur = tasks_btree.leaf_head.next; cur != &tasks_btree.leaf_head; cur = cur->next) {
     388        printf("taskid name       ctx address    as         cycles     threads "
     389            "calls  callee\n");
     390        printf("------ ---------- --- ---------- ---------- ---------- ------- "            "------ ------>\n");
     391
     392        for (cur = tasks_btree.leaf_head.next; cur != &tasks_btree.leaf_head;
     393            cur = cur->next) {
    383394                btree_node_t *node;
    384395                int i;
     
    397408                        order(task_get_accounting(t), &cycles, &suffix);
    398409                       
    399                         printf("%-6lld %-10s %-3ld %#10zx %#10zx %9llu%c %7zd %6zd", t->taskid, t->name, t->context, t, t->as, cycles, suffix, t->refcount, atomic_get(&t->active_calls));
     410                        printf("%-6lld %-10s %-3ld %#10zx %#10zx %9llu%c %7zd "
     411                            "%6zd", t->taskid, t->name, t->context, t, t->as,
     412                            cycles, suffix, t->refcount,
     413                            atomic_get(&t->active_calls));
    400414                        for (j = 0; j < IPC_MAX_PHONES; j++) {
    401415                                if (t->phones[j].callee)
    402                                         printf(" %zd:%#zx", j, t->phones[j].callee);
     416                                        printf(" %zd:%#zx", j,
     417                                            t->phones[j].callee);
    403418                        }
    404419                        printf("\n");
     
    466481       
    467482        if (t != THREAD) {
    468                 ASSERT(t != main_thread);       /* uninit is joined and detached in ktaskgc */
     483                ASSERT(t != main_thread);       /* uninit is joined and detached
     484                                                 * in ktaskgc */
    469485                thread_join(t);
    470486                thread_detach(t);
    471                 goto loop;      /* go for another thread */
     487                goto loop;                      /* go for another thread */
    472488        }
    473489       
     
    498514         * therefore the thread pointer is guaranteed to be valid.
    499515         */
    500         if (thread_join_timeout(t, 1000000, SYNCH_FLAGS_NONE) == ESYNCH_TIMEOUT) {      /* sleep uninterruptibly here! */
     516        if (thread_join_timeout(t, 1000000, SYNCH_FLAGS_NONE) ==
     517            ESYNCH_TIMEOUT) {   /* sleep uninterruptibly here! */
    501518                ipl_t ipl;
    502519                link_t *cur;
     
    504521       
    505522                /*
    506                  * The join timed out. Try to do some garbage collection of Undead threads.
     523                 * The join timed out. Try to do some garbage collection of
     524                 * Undead threads.
    507525                 */
    508526more_gc:               
     
    510528                spinlock_lock(&TASK->lock);
    511529               
    512                 for (cur = TASK->th_head.next; cur != &TASK->th_head; cur = cur->next) {
     530                for (cur = TASK->th_head.next; cur != &TASK->th_head;
     531                    cur = cur->next) {
    513532                        thr = list_get_instance(cur, thread_t, th_link);
    514533                        spinlock_lock(&thr->lock);
    515                         if (thr != t && thr->state == Undead && thr->join_type == None) {
     534                        if (thr != t && thr->state == Undead &&
     535                            thr->join_type == None) {
    516536                                thr->join_type = TaskGC;
    517537                                spinlock_unlock(&thr->lock);
  • kernel/generic/src/proc/thread.c

    r51baa8a r6f4495f5  
    205205        atomic_set(&nrdy,0);
    206206        thread_slab = slab_cache_create("thread_slab", sizeof(thread_t), 0,
    207                 thr_constructor, thr_destructor, 0);
     207            thr_constructor, thr_destructor, 0);
    208208
    209209#ifdef ARCH_HAS_FPU
    210210        fpu_context_slab = slab_cache_create("fpu_slab", sizeof(fpu_context_t),
    211                 FPU_CONTEXT_ALIGN, NULL, NULL, 0);
     211            FPU_CONTEXT_ALIGN, NULL, NULL, 0);
    212212#endif
    213213
     
    329329        /* Not needed, but good for debugging */
    330330        memsetb((uintptr_t) t->kstack, THREAD_STACK_SIZE * 1 << STACK_FRAMES,
    331                 0);
     331            0);
    332332       
    333333        ipl = interrupts_disable();
     
    339339        context_save(&t->saved_context);
    340340        context_set(&t->saved_context, FADDR(cushion), (uintptr_t) t->kstack,
    341                 THREAD_STACK_SIZE);
     341            THREAD_STACK_SIZE);
    342342       
    343343        the_initialize((the_t *) t->kstack);
     
    405405        spinlock_lock(&threads_lock);
    406406        btree_insert(&threads_btree, (btree_key_t) ((uintptr_t) t), (void *) t,
    407                 NULL);
     407            NULL);
    408408        spinlock_unlock(&threads_lock);
    409409       
     
    561561        spinlock_lock(&threads_lock);
    562562       
    563         printf("tid    name       address    state    task       ctx code       stack      cycles     cpu  kstack     waitqueue\n");
    564         printf("------ ---------- ---------- -------- ---------- --- ---------- ---------- ---------- ---- ---------- ----------\n");
    565 
    566         for (cur = threads_btree.leaf_head.next; cur != &threads_btree.leaf_head; cur = cur->next) {
     563        printf("tid    name       address    state    task       ctx code    "
     564            "   stack      cycles     cpu  kstack     waitqueue\n");
     565        printf("------ ---------- ---------- -------- ---------- --- --------"
     566            "-- ---------- ---------- ---- ---------- ----------\n");
     567
     568        for (cur = threads_btree.leaf_head.next;
     569            cur != &threads_btree.leaf_head; cur = cur->next) {
    567570                btree_node_t *node;
    568571                int i;
     
    578581                        order(t->cycles, &cycles, &suffix);
    579582                       
    580                         printf("%-6zd %-10s %#10zx %-8s %#10zx %-3ld %#10zx %#10zx %9llu%c ", t->tid, t->name, t, thread_states[t->state], t->task, t->task->context, t->thread_code, t->kstack, cycles, suffix);
     583                        printf("%-6zd %-10s %#10zx %-8s %#10zx %-3ld %#10zx "
     584                            "%#10zx %9llu%c ", t->tid, t->name, t,
     585                            thread_states[t->state], t->task, t->task->context,
     586                            t->thread_code, t->kstack, cycles, suffix);
    581587                       
    582588                        if (t->cpu)
     
    586592                       
    587593                        if (t->state == Sleeping)
    588                                 printf(" %#10zx %#10zx", t->kstack, t->sleep_queue);
     594                                printf(" %#10zx %#10zx", t->kstack,
     595                                    t->sleep_queue);
    589596                       
    590597                        printf("\n");
     
    609616        btree_node_t *leaf;
    610617       
    611         return btree_search(&threads_btree, (btree_key_t) ((uintptr_t) t), &leaf) != NULL;
     618        return btree_search(&threads_btree, (btree_key_t) ((uintptr_t) t),
     619            &leaf) != NULL;
    612620}
    613621
     
    648656        }
    649657
    650         if ((t = thread_create(uinit, kernel_uarg, TASK, THREAD_FLAG_USPACE, namebuf, false))) {
     658        t = thread_create(uinit, kernel_uarg, TASK, THREAD_FLAG_USPACE, namebuf,
     659            false);
     660        if (t) {
    651661                tid = t->tid;
    652662                thread_ready(t);
     
    671681/** @}
    672682 */
     683
  • kernel/generic/src/synch/futex.c

    r51baa8a r6f4495f5  
    103103 *
    104104 * @param uaddr Userspace address of the futex counter.
    105  * @param usec If non-zero, number of microseconds this thread is willing to sleep.
     105 * @param usec If non-zero, number of microseconds this thread is willing to
     106 *     sleep.
    106107 * @param flags Select mode of operation.
    107108 *
    108  * @return One of ESYNCH_TIMEOUT, ESYNCH_OK_ATOMIC and ESYNCH_OK_BLOCKED. See synch.h.
    109  *        If there is no physical mapping for uaddr ENOENT is returned.
     109 * @return One of ESYNCH_TIMEOUT, ESYNCH_OK_ATOMIC and ESYNCH_OK_BLOCKED. See
     110 *     synch.h. If there is no physical mapping for uaddr ENOENT is returned.
    110111 */
    111112unative_t sys_futex_sleep_timeout(uintptr_t uaddr, uint32_t usec, int flags)
     
    135136        futex = futex_find(paddr);
    136137       
    137         return (unative_t) waitq_sleep_timeout(&futex->wq, usec, flags | SYNCH_FLAGS_INTERRUPTIBLE);
     138        return (unative_t) waitq_sleep_timeout(&futex->wq, usec, flags |
     139            SYNCH_FLAGS_INTERRUPTIBLE);
    138140}
    139141
     
    243245                                 */
    244246                                futex->refcount++;
    245                                 btree_insert(&TASK->futexes, paddr, futex, leaf);
     247                                btree_insert(&TASK->futexes, paddr, futex,
     248                                    leaf);
    246249                        }
    247250                        mutex_unlock(&TASK->futexes_lock);
     
    272275/** Compute hash index into futex hash table.
    273276 *
    274  * @param key Address where the key (i.e. physical address of futex counter) is stored.
     277 * @param key Address where the key (i.e. physical address of futex counter) is
     278 *     stored.
    275279 *
    276280 * @return Index into futex hash table.
     
    283287/** Compare futex hash table item with a key.
    284288 *
    285  * @param key Address where the key (i.e. physical address of futex counter) is stored.
     289 * @param key Address where the key (i.e. physical address of futex counter) is
     290 *     stored.
    286291 *
    287292 * @return True if the item matches the key. False otherwise.
     
    317322        mutex_lock(&TASK->futexes_lock);
    318323
    319         for (cur = TASK->futexes.leaf_head.next; cur != &TASK->futexes.leaf_head; cur = cur->next) {
     324        for (cur = TASK->futexes.leaf_head.next;
     325            cur != &TASK->futexes.leaf_head; cur = cur->next) {
    320326                btree_node_t *node;
    321327                int i;
  • kernel/generic/src/synch/rwlock.c

    r51baa8a r6f4495f5  
    221221                case ESYNCH_OK_BLOCKED:         
    222222                        /*
    223                          * We were woken with rwl->readers_in already incremented.
    224                          * Note that this arrangement avoids race condition between
    225                          * two concurrent readers. (Race is avoided if 'exclusive' is
    226                          * locked at the same time as 'readers_in' is incremented.
    227                          * Same time means both events happen atomically when
    228                          * rwl->lock is held.)
     223                         * We were woken with rwl->readers_in already
     224                         * incremented.
     225                         *
     226                         * Note that this arrangement avoids race condition
     227                         * between two concurrent readers. (Race is avoided if
     228                         * 'exclusive' is locked at the same time as
     229                         * 'readers_in' is incremented. Same time means both
     230                         * events happen atomically when rwl->lock is held.)
    229231                         */
    230232                        interrupts_restore(ipl);
     
    324326
    325327        if (!list_empty(&rwl->exclusive.sem.wq.head))
    326                 t = list_get_instance(rwl->exclusive.sem.wq.head.next, thread_t, wq_link);
     328                t = list_get_instance(rwl->exclusive.sem.wq.head.next, thread_t,
     329                    wq_link);
    327330        do {
    328331                if (t) {
     
    344347                        /*
    345348                         * Waking up a reader.
    346                          * We are responsible for incrementing rwl->readers_in for it.
     349                         * We are responsible for incrementing rwl->readers_in
     350                         * for it.
    347351                         */
    348352                         rwl->readers_in++;
     
    361365                t = NULL;
    362366                if (!list_empty(&rwl->exclusive.sem.wq.head)) {
    363                         t = list_get_instance(rwl->exclusive.sem.wq.head.next, thread_t, wq_link);
     367                        t = list_get_instance(rwl->exclusive.sem.wq.head.next,
     368                            thread_t, wq_link);
    364369                        if (t) {
    365370                                spinlock_lock(&t->lock);
  • kernel/generic/src/synch/spinlock.c

    r51baa8a r6f4495f5  
    108108#endif
    109109                if (i++ > DEADLOCK_THRESHOLD) {
    110                         printf("cpu%d: looping on spinlock %.*p:%s, caller=%.*p",
    111                                CPU->id, sizeof(uintptr_t) * 2, sl, sl->name, sizeof(uintptr_t) * 2, CALLER);
     110                        printf("cpu%d: looping on spinlock %.*p:%s, "
     111                            "caller=%.*p", CPU->id, sizeof(uintptr_t) * 2, sl,
     112                            sl->name, sizeof(uintptr_t) * 2, CALLER);
    112113                        symbol = get_symtab_entry(CALLER);
    113114                        if (symbol)
  • kernel/generic/src/synch/waitq.c

    r51baa8a r6f4495f5  
    187187 * The sleep can be interrupted only if the
    188188 * SYNCH_FLAGS_INTERRUPTIBLE bit is specified in flags.
    189  
     189 *
    190190 * If usec is greater than zero, regardless of the value of the
    191191 * SYNCH_FLAGS_NON_BLOCKING bit in flags, the call will not return until either
     
    353353                THREAD->timeout_pending = true;
    354354                timeout_register(&THREAD->sleep_timeout, (uint64_t) usec,
    355                         waitq_timeouted_sleep, THREAD);
     355                    waitq_timeouted_sleep, THREAD);
    356356        }
    357357
Note: See TracChangeset for help on using the changeset viewer.