Changeset 43114c5 in mainline for src/time


Ignore:
Timestamp:
2005-04-09T18:22:53Z (21 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
8262010
Parents:
e6ba9a3f
Message:

Introduce macros CPU, THREAD, TASK and use them to replace the→cpu, the→thread, the→task.
Later on, this will make it possible to reference *current* cpu, thread and/or task without the aid from virtual memory.

Location:
src/time
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • src/time/clock.c

    re6ba9a3f r43114c5  
    5858         * run all expired timeouts as you visit them.
    5959         */
    60         spinlock_lock(&the->cpu->timeoutlock);
    61         while ((l = the->cpu->timeout_active_head.next) != &the->cpu->timeout_active_head) {
     60        spinlock_lock(&CPU->timeoutlock);
     61        while ((l = CPU->timeout_active_head.next) != &CPU->timeout_active_head) {
    6262                h = list_get_instance(l, timeout_t, link);
    6363                spinlock_lock(&h->lock);
     
    7171                timeout_reinitialize(h);
    7272                spinlock_unlock(&h->lock);     
    73                 spinlock_unlock(&the->cpu->timeoutlock);
     73                spinlock_unlock(&CPU->timeoutlock);
    7474
    7575                f(arg);
    7676
    77                 spinlock_lock(&the->cpu->timeoutlock);
     77                spinlock_lock(&CPU->timeoutlock);
    7878        }
    79         spinlock_unlock(&the->cpu->timeoutlock);
     79        spinlock_unlock(&CPU->timeoutlock);
    8080
    8181        /*
    82          * Do CPU usage accounting and find out whether to preempt the->thread.
     82         * Do CPU usage accounting and find out whether to preempt THREAD.
    8383         */
    8484
    85         if (the->thread) {
    86                 spinlock_lock(&the->cpu->lock);
    87                 the->cpu->needs_relink++;
    88                 spinlock_unlock(&the->cpu->lock);       
     85        if (THREAD) {
     86                spinlock_lock(&CPU->lock);
     87                CPU->needs_relink++;
     88                spinlock_unlock(&CPU->lock);   
    8989       
    90                 spinlock_lock(&the->thread->lock);
    91                 if (!the->thread->ticks--) {
    92                         spinlock_unlock(&the->thread->lock);
     90                spinlock_lock(&THREAD->lock);
     91                if (!THREAD->ticks--) {
     92                        spinlock_unlock(&THREAD->lock);
    9393                        scheduler();
    9494                }
    9595                else {
    96                         spinlock_unlock(&the->thread->lock);
     96                        spinlock_unlock(&THREAD->lock);
    9797                }
    9898        }
  • src/time/delay.c

    re6ba9a3f r43114c5  
    4242
    4343        pri = cpu_priority_high();
    44         asm_delay_loop(microseconds * the->cpu->delay_loop_const);
     44        asm_delay_loop(microseconds * CPU->delay_loop_const);
    4545        cpu_priority_restore(pri);
    4646}
  • src/time/timeout.c

    re6ba9a3f r43114c5  
    4040void timeout_init(void)
    4141{
    42         spinlock_initialize(&the->cpu->timeoutlock);
    43         list_initialize(&the->cpu->timeout_active_head);
     42        spinlock_initialize(&CPU->timeoutlock);
     43        list_initialize(&CPU->timeout_active_head);
    4444}
    4545
     
    7171
    7272        pri = cpu_priority_high();
    73         spinlock_lock(&the->cpu->timeoutlock);
     73        spinlock_lock(&CPU->timeoutlock);
    7474        spinlock_lock(&t->lock);
    7575   
     
    7777                panic("timeout_register: t->cpu != 0");
    7878
    79         t->cpu = the->cpu;
     79        t->cpu = CPU;
    8080        t->ticks = us2ticks(time);
    8181       
     
    8787         */
    8888        sum = 0;
    89         l = the->cpu->timeout_active_head.next;
    90         while (l != &the->cpu->timeout_active_head) {
     89        l = CPU->timeout_active_head.next;
     90        while (l != &CPU->timeout_active_head) {
    9191                hlp = list_get_instance(l, timeout_t, link);
    9292                spinlock_lock(&hlp->lock);
     
    110110         * Decrease ticks of t's immediate succesor by t->ticks.
    111111         */
    112         if (l != &the->cpu->timeout_active_head) {
     112        if (l != &CPU->timeout_active_head) {
    113113                spinlock_lock(&hlp->lock);
    114114                hlp->ticks -= t->ticks;
     
    117117
    118118        spinlock_unlock(&t->lock);
    119         spinlock_unlock(&the->cpu->timeoutlock);
     119        spinlock_unlock(&CPU->timeoutlock);
    120120        cpu_priority_restore(pri);
    121121}
Note: See TracChangeset for help on using the changeset viewer.