Changes in / [e7c077a:95b3a9c]


Ignore:
Location:
libcfa/src/concurrency
Files:
5 edited

Legend:

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

    re7c077a r95b3a9c  
    196196
    197197void __stack_clean  ( __stack_info_t * this ) {
     198        size_t size = ((intptr_t)this->storage->base) - ((intptr_t)this->storage->limit) + sizeof(__stack_t);
    198199        void * storage = this->storage->limit;
    199200
    200201        #if CFA_COROUTINE_USE_MMAP
    201                 size_t size = ((intptr_t)this->storage->base) - ((intptr_t)this->storage->limit) + sizeof(__stack_t);
    202202                storage = (void *)(((intptr_t)storage) - __page_size);
    203203                if(munmap(storage, size + __page_size) == -1) {
  • libcfa/src/concurrency/kernel.cfa

    re7c077a r95b3a9c  
    109109static void __run_thread(processor * this, $thread * dst);
    110110static void __wake_one(cluster * cltr);
    111 static void wait(__bin_sem_t & this);
    112111
    113112static void push  (__cluster_idles & idles, processor & proc);
     
    549548// Kernel Idle Sleep
    550549//=============================================================================================
    551 extern "C" {
    552         char * strerror(int);
    553 }
    554 #define CHECKED(x) { int err = x; if( err != 0 ) abort("KERNEL ERROR: Operation \"" #x "\" return error %d - %s\n", err, strerror(err)); }
    555 
    556 static void wait(__bin_sem_t & this) with( this ) {
    557         verify(__cfaabi_dbg_in_kernel());
    558         CHECKED( pthread_mutex_lock(&lock) );
    559                 while(val < 1) {
    560                         pthread_cond_wait(&cond, &lock);
    561                 }
    562                 val -= 1;
    563         CHECKED( pthread_mutex_unlock(&lock) );
    564 }
    565 
    566 static bool post(__bin_sem_t & this) with( this ) {
    567         bool needs_signal = false;
    568 
    569         CHECKED( pthread_mutex_lock(&lock) );
    570                 if(val < 1) {
    571                         val += 1;
    572                         pthread_cond_signal(&cond);
    573                         needs_signal = true;
    574                 }
    575         CHECKED( pthread_mutex_unlock(&lock) );
    576 
    577         return needs_signal;
    578 }
    579 
    580 #undef CHECKED
    581 
    582550// Wake a thread from the front if there are any
    583551static void __wake_one(cluster * this) {
  • libcfa/src/concurrency/kernel.hfa

    re7c077a r95b3a9c  
    3434#endif
    3535
     36extern "C" {
     37        char * strerror(int);
     38}
     39#define CHECKED(x) { int err = x; if( err != 0 ) abort("KERNEL ERROR: Operation \"" #x "\" return error %d - %s\n", err, strerror(err)); }
     40
    3641struct __bin_sem_t {
    3742        pthread_mutex_t         lock;
     
    3944        int                     val;
    4045};
     46
     47static inline void ?{}(__bin_sem_t & this) with( this ) {
     48        // Create the mutex with error checking
     49        pthread_mutexattr_t mattr;
     50        pthread_mutexattr_init( &mattr );
     51        pthread_mutexattr_settype( &mattr, PTHREAD_MUTEX_ERRORCHECK_NP);
     52        pthread_mutex_init(&lock, &mattr);
     53
     54        pthread_cond_init (&cond, (const pthread_condattr_t *)0p);  // workaround trac#208: cast should not be required
     55        val = 0;
     56}
     57
     58static inline void ^?{}(__bin_sem_t & this) with( this ) {
     59        CHECKED( pthread_mutex_destroy(&lock) );
     60        CHECKED( pthread_cond_destroy (&cond) );
     61}
     62
     63static inline void wait(__bin_sem_t & this) with( this ) {
     64        verify(__cfaabi_dbg_in_kernel());
     65        CHECKED( pthread_mutex_lock(&lock) );
     66                while(val < 1) {
     67                        pthread_cond_wait(&cond, &lock);
     68                }
     69                val -= 1;
     70        CHECKED( pthread_mutex_unlock(&lock) );
     71}
     72
     73static inline bool post(__bin_sem_t & this) with( this ) {
     74        bool needs_signal = false;
     75
     76        CHECKED( pthread_mutex_lock(&lock) );
     77                if(val < 1) {
     78                        val += 1;
     79                        pthread_cond_signal(&cond);
     80                        needs_signal = true;
     81                }
     82        CHECKED( pthread_mutex_unlock(&lock) );
     83
     84        return needs_signal;
     85}
     86
     87#undef CHECKED
     88
    4189
    4290//-----------------------------------------------------------------------------
  • libcfa/src/concurrency/kernel/startup.cfa

    re7c077a r95b3a9c  
    8080static void ?{}(processorCtx_t & this) {}
    8181static void ?{}(processorCtx_t & this, processor * proc, current_stack_info_t * info);
    82 static void ?{}(__bin_sem_t & this);
    83 static void ^?{}(__bin_sem_t & this);
    8482
    8583#if defined(__CFA_WITH_VERIFY__)
     
    738736}
    739737
    740 extern "C" {
    741         char * strerror(int);
    742 }
    743 #define CHECKED(x) { int err = x; if( err != 0 ) abort("KERNEL ERROR: Operation \"" #x "\" return error %d - %s\n", err, strerror(err)); }
    744 
    745 static void ?{}(__bin_sem_t & this) with( this ) {
    746         // Create the mutex with error checking
    747         pthread_mutexattr_t mattr;
    748         pthread_mutexattr_init( &mattr );
    749         pthread_mutexattr_settype( &mattr, PTHREAD_MUTEX_ERRORCHECK_NP);
    750         pthread_mutex_init(&lock, &mattr);
    751 
    752         pthread_cond_init (&cond, (const pthread_condattr_t *)0p);  // workaround trac#208: cast should not be required
    753         val = 0;
    754 }
    755 
    756 static void ^?{}(__bin_sem_t & this) with( this ) {
    757         CHECKED( pthread_mutex_destroy(&lock) );
    758         CHECKED( pthread_cond_destroy (&cond) );
    759 }
    760 
    761 #undef CHECKED
    762738
    763739#if defined(__CFA_WITH_VERIFY__)
  • libcfa/src/concurrency/ready_queue.cfa

    re7c077a r95b3a9c  
    330330        #if defined(BIAS)
    331331                // Don't bother trying locally too much
     332                int local_tries = 8;
    332333                preferred = kernelTLS().this_processor->id * 4;
    333334        #endif
Note: See TracChangeset for help on using the changeset viewer.