Ignore:
Timestamp:
Jun 23, 2017, 11:22:59 AM (7 years ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
Children:
7bbba76
Parents:
d43cd01
Message:

Added macros for parameters only present in debug

Location:
src/libcfa/concurrency
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • src/libcfa/concurrency/alarm.c

    rd43cd01 r2ac095d  
    2424}
    2525
     26#include "libhdr.h"
     27
    2628#include "alarm.h"
    2729#include "kernel_private.h"
    28 #include "libhdr.h"
    2930#include "preemption.h"
    3031
     
    154155        disable_interrupts();
    155156        verify( !systemProcessor->pending_alarm );
    156         lock( &systemProcessor->alarm_lock, __PRETTY_FUNCTION__ );
     157        lock( &systemProcessor->alarm_lock DEBUG_CTX2 );
    157158        {
    158159                verify( validate( &systemProcessor->alarms ) );
     
    169170        unlock( &systemProcessor->alarm_lock );
    170171        this->set = true;
    171         enable_interrupts( __PRETTY_FUNCTION__ );
     172        enable_interrupts( DEBUG_CTX );
    172173}
    173174
     
    175176        // LIB_DEBUG_PRINT_BUFFER_DECL( STDERR_FILENO, "Kernel : unregister %p start\n", this );
    176177        disable_interrupts();
    177         lock( &systemProcessor->alarm_lock, __PRETTY_FUNCTION__ );
     178        lock( &systemProcessor->alarm_lock DEBUG_CTX2 );
    178179        {
    179180                verify( validate( &systemProcessor->alarms ) );
     
    181182        }
    182183        unlock( &systemProcessor->alarm_lock );
    183         disable_interrupts();
     184        enable_interrupts( DEBUG_CTX );
    184185        this->set = false;
    185186        // LIB_DEBUG_PRINT_BUFFER_LOCAL( STDERR_FILENO, "Kernel : unregister %p end\n", this );
  • src/libcfa/concurrency/invoke.c

    rd43cd01 r2ac095d  
    3131extern void __leave_thread_monitor( struct thread_desc * this );
    3232extern void disable_interrupts();
    33 extern void enable_interrupts( const char * );
     33extern void enable_interrupts( DEBUG_CTX_PARAM );
    3434
    3535void CtxInvokeCoroutine(
     
    7171
    7272      // Officially start the thread by enabling preemption
    73       enable_interrupts( __PRETTY_FUNCTION__ );
     73      enable_interrupts( DEBUG_CTX );
    7474
    7575      // Call the main of the thread
  • src/libcfa/concurrency/kernel

    rd43cd01 r2ac095d  
    2828//-----------------------------------------------------------------------------
    2929// Locks
    30 bool try_lock( spinlock *
    31         #ifdef __CFA_DEBUG__
    32                 , const char * caller
    33         #endif
    34 );
    35 
    36 void lock( spinlock *
    37         #ifdef __CFA_DEBUG__
    38                 , const char * caller
    39         #endif
    40 );
    41 
    42 void unlock( spinlock * );
     30bool try_lock( spinlock * DEBUG_CTX_PARAM2 );
     31void lock    ( spinlock * DEBUG_CTX_PARAM2 );
     32void unlock  ( spinlock * );
    4333
    4434struct signal_once {
     
    7868        unsigned short thrd_count;
    7969};
    80 static inline void ?{}(FinishAction * this) { 
     70static inline void ?{}(FinishAction * this) {
    8171        this->action_code = No_Action;
    8272        this->thrd = NULL;
     
    8979        cluster * cltr;
    9080        pthread_t kernel_thread;
    91        
     81
    9282        signal_once terminated;
    9383        volatile bool is_terminated;
  • src/libcfa/concurrency/kernel.c

    rd43cd01 r2ac095d  
    1515//
    1616
    17 #include "startup.h"
    18 
    19 //Start and stop routine for the kernel, declared first to make sure they run first
    20 void kernel_startup(void)  __attribute__(( constructor( STARTUP_PRIORITY_KERNEL ) ));
    21 void kernel_shutdown(void) __attribute__(( destructor ( STARTUP_PRIORITY_KERNEL ) ));
    22 
    23 //Header
    24 #include "kernel_private.h"
     17#include "libhdr.h"
    2518
    2619//C Includes
     
    3528
    3629//CFA Includes
    37 #include "libhdr.h"
     30#include "kernel_private.h"
    3831#include "preemption.h"
     32#include "startup.h"
    3933
    4034//Private includes
    4135#define __CFA_INVOKE_PRIVATE__
    4236#include "invoke.h"
     37
     38//Start and stop routine for the kernel, declared first to make sure they run first
     39void kernel_startup(void)  __attribute__(( constructor( STARTUP_PRIORITY_KERNEL ) ));
     40void kernel_shutdown(void) __attribute__(( destructor ( STARTUP_PRIORITY_KERNEL ) ));
    4341
    4442//-----------------------------------------------------------------------------
     
    369367        verifyf( thrd->next == NULL, "Expected null got %p", thrd->next );
    370368
    371         lock( &systemProcessor->proc.cltr->lock, __PRETTY_FUNCTION__ );
     369        lock( &systemProcessor->proc.cltr->lock DEBUG_CTX2 );
    372370        append( &systemProcessor->proc.cltr->ready_queue, thrd );
    373371        unlock( &systemProcessor->proc.cltr->lock );
     
    378376thread_desc * nextThread(cluster * this) {
    379377        verify( disable_preempt_count > 0 );
    380         lock( &this->lock, __PRETTY_FUNCTION__ );
     378        lock( &this->lock DEBUG_CTX2 );
    381379        thread_desc * head = pop_head( &this->ready_queue );
    382380        unlock( &this->lock );
     
    390388        suspend();
    391389        verify( disable_preempt_count > 0 );
    392         enable_interrupts( __PRETTY_FUNCTION__ );
     390        enable_interrupts( DEBUG_CTX );
    393391}
    394392
     
    402400        verify( disable_preempt_count > 0 );
    403401
    404         enable_interrupts( __PRETTY_FUNCTION__ );
     402        enable_interrupts( DEBUG_CTX );
    405403}
    406404
     
    415413        verify( disable_preempt_count > 0 );
    416414
    417         enable_interrupts( __PRETTY_FUNCTION__ );
     415        enable_interrupts( DEBUG_CTX );
    418416}
    419417
     
    428426        verify( disable_preempt_count > 0 );
    429427
    430         enable_interrupts( __PRETTY_FUNCTION__ );
     428        enable_interrupts( DEBUG_CTX );
    431429}
    432430
     
    441439        verify( disable_preempt_count > 0 );
    442440
    443         enable_interrupts( __PRETTY_FUNCTION__ );
     441        enable_interrupts( DEBUG_CTX );
    444442}
    445443
     
    456454        verify( disable_preempt_count > 0 );
    457455
    458         enable_interrupts( __PRETTY_FUNCTION__ );
     456        enable_interrupts( DEBUG_CTX );
    459457}
    460458
     
    510508        LIB_DEBUG_PRINT_SAFE("Kernel : Started\n--------------------------------------------------\n\n");
    511509
    512         enable_interrupts( __PRETTY_FUNCTION__ );
     510        enable_interrupts( DEBUG_CTX );
    513511}
    514512
     
    548546        // abort cannot be recursively entered by the same or different processors because all signal handlers return when
    549547        // the globalAbort flag is true.
    550         lock( &kernel_abort_lock, __PRETTY_FUNCTION__ );
     548        lock( &kernel_abort_lock DEBUG_CTX2 );
    551549
    552550        // first task to abort ?
     
    586584extern "C" {
    587585        void __lib_debug_acquire() {
    588                 lock(&kernel_debug_lock, __PRETTY_FUNCTION__);
     586                lock( &kernel_debug_lock DEBUG_CTX2 );
    589587        }
    590588
    591589        void __lib_debug_release() {
    592                 unlock(&kernel_debug_lock);
     590                unlock( &kernel_debug_lock );
    593591        }
    594592}
     
    606604}
    607605
    608 bool try_lock( spinlock * this, const char * caller ) {
     606bool try_lock( spinlock * this DEBUG_CTX_PARAM2 ) {
    609607        bool ret = this->lock == 0 && __sync_lock_test_and_set_4( &this->lock, 1 ) == 0;
    610         this->prev = caller;
     608        LIB_DEBUG_DO( this->prev = caller; )
    611609        return ret;
    612610}
    613611
    614 void lock( spinlock * this, const char * caller ) {
     612void lock( spinlock * this DEBUG_CTX_PARAM2 ) {
    615613        for ( unsigned int i = 1;; i += 1 ) {
    616614                if ( this->lock == 0 && __sync_lock_test_and_set_4( &this->lock, 1 ) == 0 ) break;
    617615        }
    618         this->prev = caller;
     616        LIB_DEBUG_DO( this->prev = caller; )
    619617}
    620618
     
    631629
    632630void wait( signal_once * this ) {
    633         lock( &this->lock, __PRETTY_FUNCTION__ );
     631        lock( &this->lock DEBUG_CTX2 );
    634632        if( !this->cond ) {
    635633                append( &this->blocked, (thread_desc*)this_thread );
     
    642640
    643641void signal( signal_once * this ) {
    644         lock( &this->lock, __PRETTY_FUNCTION__ );
     642        lock( &this->lock DEBUG_CTX2 );
    645643        {
    646644                this->cond = true;
     
    651649                        ScheduleThread( it );
    652650                }
    653                 enable_interrupts( __PRETTY_FUNCTION__ );
     651                enable_interrupts( DEBUG_CTX );
    654652        }
    655653        unlock( &this->lock );
  • src/libcfa/concurrency/kernel_private.h

    rd43cd01 r2ac095d  
    1818#define KERNEL_PRIVATE_H
    1919
     20#include "libhdr.h"
     21
    2022#include "kernel"
    2123#include "thread"
     
    2325#include "alarm.h"
    2426
    25 #include "libhdr.h"
    2627
    2728//-----------------------------------------------------------------------------
     
    3132        void disable_interrupts();
    3233        void enable_interrupts_noRF();
    33         void enable_interrupts( const char * );
     34        void enable_interrupts( DEBUG_CTX_PARAM );
    3435}
    3536
     
    4041        disable_interrupts();
    4142        ScheduleThread( thrd );
    42         enable_interrupts( __PRETTY_FUNCTION__ );
     43        enable_interrupts( DEBUG_CTX );
    4344}
    4445thread_desc * nextThread(cluster * this);
  • src/libcfa/concurrency/monitor.c

    rd43cd01 r2ac095d  
    1919#include <stdlib>
    2020
     21#include "libhdr.h"
    2122#include "kernel_private.h"
    22 #include "libhdr.h"
    2323
    2424//-----------------------------------------------------------------------------
     
    4545extern "C" {
    4646        void __enter_monitor_desc( monitor_desc * this ) {
    47                 lock( &this->lock, __PRETTY_FUNCTION__ );
     47                lock( &this->lock DEBUG_CTX2 );
    4848                thread_desc * thrd = this_thread;
    4949
     
    6666
    6767                        //BlockInternal will unlock spinlock, no need to unlock ourselves
    68                         return; 
     68                        return;
    6969                }
    7070
     
    7676        //      TODO
    7777        void __leave_monitor_desc( monitor_desc * this ) {
    78                 lock( &this->lock, __PRETTY_FUNCTION__ );
     78                lock( &this->lock DEBUG_CTX2 );
    7979
    8080                // LIB_DEBUG_PRINT_SAFE("%p Leaving %p (o: %p, r: %i). ", this_thread, this, this->owner, this->recursion);
     
    104104        void __leave_thread_monitor( thread_desc * thrd ) {
    105105                monitor_desc * this = &thrd->mon;
    106                 lock( &this->lock, __PRETTY_FUNCTION__ );
     106                lock( &this->lock DEBUG_CTX2 );
    107107
    108108                disable_interrupts();
     
    260260
    261261        unsigned short count = this->monitor_count;
    262        
     262
    263263        //Some more checking in debug
    264264        LIB_DEBUG_DO(
     
    354354
    355355uintptr_t front( condition * this ) {
    356         verifyf( !is_empty(this), 
     356        verifyf( !is_empty(this),
    357357                "Attempt to access user data on an empty condition.\n"
    358358                "Possible cause is not checking if the condition is empty before reading stored data."
     
    422422static inline void lock_all( spinlock ** locks, unsigned short count ) {
    423423        for( int i = 0; i < count; i++ ) {
    424                 lock( locks[i], __PRETTY_FUNCTION__ );
     424                lock( locks[i] DEBUG_CTX2 );
    425425        }
    426426}
     
    429429        for( int i = 0; i < count; i++ ) {
    430430                spinlock * l = &source[i]->lock;
    431                 lock( l, __PRETTY_FUNCTION__ );
     431                lock( l DEBUG_CTX2 );
    432432                if(locks) locks[i] = l;
    433433        }
  • src/libcfa/concurrency/preemption.c

    rd43cd01 r2ac095d  
    1515//
    1616
     17#include "libhdr.h"
    1718#include "preemption.h"
    18 
    1919
    2020extern "C" {
     
    3333#include "fstream"
    3434#endif
    35 #include "libhdr.h"
    3635
    3736#define __CFA_DEFAULT_PREEMPTION__ 10000
     
    167166
    168167        void enable_interrupts_noRF() {
    169                 unsigned short prev = __atomic_fetch_add_2( &disable_preempt_count, -1, __ATOMIC_SEQ_CST );
     168                __attribute__((unused)) unsigned short prev = __atomic_fetch_add_2( &disable_preempt_count, -1, __ATOMIC_SEQ_CST );
    170169                verify( prev != (unsigned short) 0 );
    171170        }
    172171
    173         void enable_interrupts( const char * func ) {
     172        void enable_interrupts( DEBUG_CTX_PARAM ) {
    174173                processor * proc   = this_processor;
    175174                thread_desc * thrd = this_thread;
     
    183182                }
    184183
    185                 proc->last_enable = func;
     184                LIB_DEBUG_DO( proc->last_enable = caller; )
    186185        }
    187186}
     
    238237        // if( ((intptr_t)cxt->uc_mcontext.gregs[REG_RIP]) > 0xFFFFFF ) __debug_break();
    239238
    240         if( try_lock( &systemProcessor->alarm_lock, __PRETTY_FUNCTION__ ) ) {
     239        if( try_lock( &systemProcessor->alarm_lock DEBUG_CTX2 ) ) {
    241240                tick_preemption();
    242241                unlock( &systemProcessor->alarm_lock );
  • src/libcfa/concurrency/thread.c

    rd43cd01 r2ac095d  
    8383
    8484        ScheduleThread(thrd_h);
    85         enable_interrupts( __PRETTY_FUNCTION__ );
     85        enable_interrupts( DEBUG_CTX );
    8686}
    8787
Note: See TracChangeset for help on using the changeset viewer.