Changeset da1bafb in mainline for kernel/generic/src/console/cmd.c


Ignore:
Timestamp:
2010-05-24T18:57:31Z (14 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
0095368
Parents:
666f492
Message:

major code revision

  • replace spinlocks taken with interrupts disabled with irq_spinlocks
  • change spacing (not indendation) to be tab-size independent
  • use unsigned integer types where appropriate (especially bit flags)
  • visual separation
  • remove argument names in function prototypes
  • string changes
  • correct some formating directives
  • replace various cryptic single-character variables (t, a, m, c, b, etc.) with proper identifiers (thread, task, timeout, as, itm, itc, etc.)
  • unify some assembler constructs
  • unused page table levels are now optimized out in compile time
  • replace several ints (with boolean semantics) with bools
  • use specifically sized types instead of generic types where appropriate (size_t, uint32_t, btree_key_t)
  • improve comments
  • split asserts with conjuction into multiple independent asserts
File:
1 edited

Legend:

Unmodified
Added
Removed
  • kernel/generic/src/console/cmd.c

    r666f492 rda1bafb  
    510510void cmd_initialize(cmd_info_t *cmd)
    511511{
    512         spinlock_initialize(&cmd->lock, "cmd");
     512        spinlock_initialize(&cmd->lock, "cmd.lock");
    513513        link_initialize(&cmd->link);
    514514}
     
    681681                        continue;
    682682               
    683                 thread_t *t;
    684                 if ((t = thread_create((void (*)(void *)) cmd_call0, (void *) argv, TASK, THREAD_FLAG_WIRED, "call0", false))) {
    685                         spinlock_lock(&t->lock);
    686                         t->cpu = &cpus[i];
    687                         spinlock_unlock(&t->lock);
    688                         printf("cpu%u: ", i);
    689                         thread_ready(t);
    690                         thread_join(t);
    691                         thread_detach(t);
     683                thread_t *thread;
     684                if ((thread = thread_create((void (*)(void *)) cmd_call0,
     685                    (void *) argv, TASK, THREAD_FLAG_WIRED, "call0", false))) {
     686                        irq_spinlock_lock(&thread->lock, true);
     687                        thread->cpu = &cpus[i];
     688                        irq_spinlock_unlock(&thread->lock, true);
     689                       
     690                        printf("cpu%" PRIs ": ", i);
     691                       
     692                        thread_ready(thread);
     693                        thread_join(thread);
     694                        thread_detach(thread);
    692695                } else
    693                         printf("Unable to create thread for cpu%u\n", i);
     696                        printf("Unable to create thread for cpu%" PRIs "\n", i);
    694697        }
    695698       
     
    10491052        /* Update and read thread accounting
    10501053           for benchmarking */
    1051         ipl_t ipl = interrupts_disable();
    1052         spinlock_lock(&TASK->lock);
     1054        irq_spinlock_lock(&TASK->lock, true);
    10531055        uint64_t ucycles0, kcycles0;
    10541056        task_get_accounting(TASK, &ucycles0, &kcycles0);
    1055         spinlock_unlock(&TASK->lock);
    1056         interrupts_restore(ipl);
     1057        irq_spinlock_unlock(&TASK->lock, true);
    10571058       
    10581059        /* Execute the test */
     
    10611062       
    10621063        /* Update and read thread accounting */
    1063         uint64_t ucycles1, kcycles1;
    1064         ipl = interrupts_disable();
    1065         spinlock_lock(&TASK->lock);
     1064        uint64_t ucycles1, kcycles1;
     1065        irq_spinlock_lock(&TASK->lock, true);
    10661066        task_get_accounting(TASK, &ucycles1, &kcycles1);
    1067         spinlock_unlock(&TASK->lock);
    1068         interrupts_restore(ipl);
     1067        irq_spinlock_unlock(&TASK->lock, true);
    10691068       
    10701069        uint64_t ucycles, kcycles;
     
    10721071        order_suffix(ucycles1 - ucycles0, &ucycles, &usuffix);
    10731072        order_suffix(kcycles1 - kcycles0, &kcycles, &ksuffix);
    1074                
     1073       
    10751074        printf("Time: %" PRIu64 "%c user cycles, %" PRIu64 "%c kernel cycles\n",
    1076                         ucycles, usuffix, kcycles, ksuffix);
     1075            ucycles, usuffix, kcycles, ksuffix);
    10771076       
    10781077        if (ret == NULL) {
     
    10801079                return true;
    10811080        }
    1082 
     1081       
    10831082        printf("%s\n", ret);
    10841083        return false;
     
    11061105                /* Update and read thread accounting
    11071106                   for benchmarking */
    1108                 ipl_t ipl = interrupts_disable();
    1109                 spinlock_lock(&TASK->lock);
     1107                irq_spinlock_lock(&TASK->lock, true);
    11101108                uint64_t ucycles0, kcycles0;
    11111109                task_get_accounting(TASK, &ucycles0, &kcycles0);
    1112                 spinlock_unlock(&TASK->lock);
    1113                 interrupts_restore(ipl);
     1110                irq_spinlock_unlock(&TASK->lock, true);
    11141111               
    11151112                /* Execute the test */
     
    11181115               
    11191116                /* Update and read thread accounting */
    1120                 ipl = interrupts_disable();
    1121                 spinlock_lock(&TASK->lock);
     1117                irq_spinlock_lock(&TASK->lock, true);
    11221118                uint64_t ucycles1, kcycles1;
    11231119                task_get_accounting(TASK, &ucycles1, &kcycles1);
    1124                 spinlock_unlock(&TASK->lock);
    1125                 interrupts_restore(ipl);
    1126 
     1120                irq_spinlock_unlock(&TASK->lock, true);
     1121               
    11271122                if (ret != NULL) {
    11281123                        printf("%s\n", ret);
     
    11351130                order_suffix(kcycles1 - kcycles0, &kcycles, &ksuffix);
    11361131                printf("OK (%" PRIu64 "%c user cycles, %" PRIu64 "%c kernel cycles)\n",
    1137                                 ucycles, usuffix, kcycles, ksuffix);
     1132                    ucycles, usuffix, kcycles, ksuffix);
    11381133        }
    11391134       
Note: See TracChangeset for help on using the changeset viewer.