Ignore:
Timestamp:
Apr 5, 2021, 7:06:37 PM (6 months ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
arm-eh, jacob/cs343-translation, master, new-ast-unique-expr
Children:
7039ab9, cd59d28
Parents:
a5a01fa
Message:

Kernel now keeps track of the how many threads each processor has contributed.
This isn't useful if it is not sampled regularly but it's a first step.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • libcfa/src/concurrency/kernel.cfa

    ra5a01fa rec43cf9  
    357357                                break RUNNING;
    358358                        case TICKET_UNBLOCK:
     359                                #if !defined(__CFA_NO_STATISTICS__)
     360                                        __tls_stats()->ready.threads.threads++;
     361                                #endif
    359362                                // This is case 2, the racy case, someone tried to run this thread before it finished blocking
    360363                                // In this case, just run it again.
     
    370373
    371374        __cfadbg_print_safe(runtime_core, "Kernel : core %p finished running thread %p\n", this, thrd_dst);
     375
     376        #if !defined(__CFA_NO_STATISTICS__)
     377                __tls_stats()->ready.threads.threads--;
     378        #endif
    372379
    373380        /* paranoid */ verify( ! __preemption_enabled() );
     
    432439        if (thrd->preempted == __NO_PREEMPTION) thrd->state = Ready;
    433440
     441        // Dereference the thread now because once we push it, there is not guaranteed it's still valid.
     442        struct cluster * cl = thrd->curr_cluster;
     443
    434444        ready_schedule_lock();
    435                 // Dereference the thread now because once we push it, there is not guaranteed it's still valid.
    436                 struct cluster * cl = thrd->curr_cluster;
    437 
    438445                // push the thread to the cluster ready-queue
    439446                push( cl, thrd );
     
    444451                __wake_one( cl );
    445452        ready_schedule_unlock();
     453
     454        #if !defined(__CFA_NO_STATISTICS__)
     455                if( kernelTLS().this_stats ) {
     456                        __tls_stats()->ready.threads.threads++;
     457                }
     458                else {
     459                        __atomic_fetch_add(&cl->stats->ready.threads.threads, 1, __ATOMIC_RELAXED);
     460                }
     461        #endif
    446462
    447463        /* paranoid */ verify( ! __preemption_enabled() );
Note: See TracChangeset for help on using the changeset viewer.