Changeset 4233338b


Ignore:
Timestamp:
Jan 10, 2022, 4:07:04 PM (3 years ago)
Author:
caparsons <caparson@…>
Branches:
ADT, ast-experimental, enum, forall-pointer-decay, master, pthread-emulation, qualifiedEnum
Children:
56d711f
Parents:
0ac728b (diff), 7d0ebd0 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'master' of plg.uwaterloo.ca:software/cfa/cfa-cc

Files:
2 added
1 deleted
8 edited
1 moved

Legend:

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

    r0ac728b r4233338b  
    1010// Created On       : Mon Nov 28 12:27:26 2016
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue Feb  4 12:29:26 2020
    13 // Update Count     : 11
     12// Last Modified On : Thu Jan  6 16:33:16 2022
     13// Update Count     : 12
    1414//
    1515
     
    155155
    156156        if( unlikely(dst->context.SP == 0p) ) {
    157                 __stack_prepare(&dst->stack, 65000);
     157                __stack_prepare(&dst->stack, DEFAULT_STACK_SIZE);
    158158                __cfactx_start(main, dst, cor, __cfactx_invoke_coroutine);
    159159        }
  • libcfa/src/concurrency/invoke.h

    r0ac728b r4233338b  
    1010// Created On       : Tue Jan 17 12:27:26 2016
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Dec  5 16:26:03 2019
    13 // Update Count     : 44
     12// Last Modified On : Thu Jan  6 16:37:40 2022
     13// Update Count     : 47
    1414//
    1515
     
    2727#ifndef _INVOKE_H_
    2828#define _INVOKE_H_
     29
     30        enum { DEFAULT_STACK_SIZE = 65000 };
    2931
    3032        struct __cfaehm_try_resume_node;
  • libcfa/src/concurrency/kernel.cfa

    r0ac728b r4233338b  
    142142extern void __disable_interrupts_hard();
    143143extern void __enable_interrupts_hard();
    144 
    145 static inline void __disable_interrupts_checked() {
    146         /* paranoid */ verify( __preemption_enabled() );
    147         disable_interrupts();
    148         /* paranoid */ verify( ! __preemption_enabled() );
    149 }
    150 
    151 static inline void __enable_interrupts_checked( bool poll = true ) {
    152         /* paranoid */ verify( ! __preemption_enabled() );
    153         enable_interrupts( poll );
    154         /* paranoid */ verify( __preemption_enabled() );
    155 }
    156144
    157145
     
    776764// Unconditionnaly wake a thread
    777765void __wake_proc(processor * this) {
     766        /* paranoid */ verify( ! __preemption_enabled() );
     767
    778768        __cfadbg_print_safe(runtime_core, "Kernel : waking Processor %p\n", this);
    779769
    780         __disable_interrupts_checked();
    781                 /* paranoid */ verify( ! __preemption_enabled() );
    782                 eventfd_t val;
    783                 val = 1;
    784                 eventfd_write( this->idle_fd, val );
    785         __enable_interrupts_checked();
     770        eventfd_t val;
     771        val = 1;
     772        eventfd_write( this->idle_fd, val );
     773
     774        /* paranoid */ verify( ! __preemption_enabled() );
    786775}
    787776
  • libcfa/src/concurrency/kernel/startup.cfa

    r0ac728b r4233338b  
    279279        // When its coroutine terminates, it return control to the mainThread
    280280        // which is currently here
     281        /* paranoid */ verify( !__atomic_load_n(&mainProcessor->do_terminate, __ATOMIC_ACQUIRE) );
    281282        __atomic_store_n(&mainProcessor->do_terminate, true, __ATOMIC_RELEASE);
     283        __wake_proc( mainProcessor );
    282284        __kernel_last_resume( __cfaabi_tls.this_processor );
    283285        mainThread->self_cor.state = Halted;
     
    403405
    404406        __cfaabi_tls.this_thread->curr_cor = dst;
    405         __stack_prepare( &dst->stack, 65000 );
     407        __stack_prepare( &dst->stack, DEFAULT_STACK_SIZE );
    406408        __cfactx_start(main, dst, this->runner, __cfactx_invoke_coroutine);
    407409
     
    564566extern size_t __page_size;
    565567void ^?{}(processor & this) with( this ){
    566         if( ! __atomic_load_n(&do_terminate, __ATOMIC_ACQUIRE) ) {
    567                 __cfadbg_print_safe(runtime_core, "Kernel : core %p signaling termination\n", &this);
    568 
    569                 __atomic_store_n(&do_terminate, true, __ATOMIC_RELAXED);
     568        /* paranoid */ verify( !__atomic_load_n(&do_terminate, __ATOMIC_ACQUIRE) );
     569        __cfadbg_print_safe(runtime_core, "Kernel : core %p signaling termination\n", &this);
     570
     571        __atomic_store_n(&do_terminate, true, __ATOMIC_RELAXED);
     572        __disable_interrupts_checked();
    570573                __wake_proc( &this );
    571 
    572                 wait( terminated );
    573                 /* paranoid */ verify( active_processor() != &this);
    574         }
     574        __enable_interrupts_checked();
     575
     576        wait( terminated );
     577        /* paranoid */ verify( active_processor() != &this);
    575578
    576579        __destroy_pthread( kernel_thread, this.stack, 0p );
     
    721724        check( pthread_attr_init( &attr ), "pthread_attr_init" ); // initialize attribute
    722725
    723         size_t stacksize;
    724         // default stack size, normally defined by shell limit
    725         check( pthread_attr_getstacksize( &attr, &stacksize ), "pthread_attr_getstacksize" );
    726         assert( stacksize >= PTHREAD_STACK_MIN );
     726        size_t stacksize = DEFAULT_STACK_SIZE;
    727727
    728728        void * stack;
     
    749749        #endif
    750750
    751 
    752751        check( pthread_attr_setstack( &attr, stack, stacksize ), "pthread_attr_setstack" );
    753 
    754752        check( pthread_create( pthread, &attr, start, arg ), "pthread_create" );
    755753        return stack;
  • libcfa/src/concurrency/kernel_private.hfa

    r0ac728b r4233338b  
    6060extern bool __preemption_enabled();
    6161
     62static inline void __disable_interrupts_checked() {
     63        /* paranoid */ verify( __preemption_enabled() );
     64        disable_interrupts();
     65        /* paranoid */ verify( ! __preemption_enabled() );
     66}
     67
     68static inline void __enable_interrupts_checked( bool poll = true ) {
     69        /* paranoid */ verify( ! __preemption_enabled() );
     70        enable_interrupts( poll );
     71        /* paranoid */ verify( __preemption_enabled() );
     72}
     73
    6274//release/wake-up the following resources
    6375void __thread_finish( thread$ * thrd );
  • libcfa/src/concurrency/locks.hfa

    r0ac728b r4233338b  
    177177};
    178178
     179static inline void ?{}(fast_lock & this) __attribute__((deprecated("use linear_backoff_then_block_lock instead")));
    179180static inline void ?{}(fast_lock & this) { this.owner = 0p; }
    180181
     
    184185}
    185186
    186 static inline void lock( fast_lock & this ) __attribute__((artificial));
     187static inline void lock( fast_lock & this ) __attribute__((deprecated("use linear_backoff_then_block_lock instead"), artificial));
    187188static inline void lock( fast_lock & this ) {
    188189        thread$ * thrd = active_thread();
     
    195196}
    196197
    197 static inline bool try_lock( fast_lock & this ) __attribute__((artificial));
     198static inline bool try_lock( fast_lock & this ) __attribute__((deprecated("use linear_backoff_then_block_lock instead"), artificial));
    198199static inline bool try_lock ( fast_lock & this ) {
    199200        thread$ * thrd = active_thread();
     
    202203}
    203204
    204 static inline thread$ * unlock( fast_lock & this ) __attribute__((artificial));
     205static inline thread$ * unlock( fast_lock & this ) __attribute__((deprecated("use linear_backoff_then_block_lock instead"), artificial));
    205206static inline thread$ * unlock( fast_lock & this ) {
    206207        /* paranoid */ verify(active_thread() == this.owner);
  • libcfa/src/concurrency/thread.hfa

    r0ac728b r4233338b  
    1010// Created On       : Tue Jan 17 12:27:26 2017
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Dec  4 09:18:14 2019
    13 // Update Count     : 6
     12// Last Modified On : Thu Jan  6 16:40:16 2022
     13// Update Count     : 7
    1414//
    1515
     
    6565void ^?{}(thread$ & this);
    6666
    67 static inline void ?{}(thread$ & this)                                                                  { this{ "Anonymous Thread", *mainCluster, 0p, 65000 }; }
     67static inline void ?{}(thread$ & this)                                                                  { this{ "Anonymous Thread", *mainCluster, 0p, DEFAULT_STACK_SIZE }; }
    6868static inline void ?{}(thread$ & this, size_t stackSize )                                               { this{ "Anonymous Thread", *mainCluster, 0p, stackSize }; }
    6969static inline void ?{}(thread$ & this, void * storage, size_t storageSize )                             { this{ "Anonymous Thread", *mainCluster, storage, storageSize }; }
    70 static inline void ?{}(thread$ & this, struct cluster & cl )                                            { this{ "Anonymous Thread", cl, 0p, 65000 }; }
     70static inline void ?{}(thread$ & this, struct cluster & cl )                                            { this{ "Anonymous Thread", cl, 0p, DEFAULT_STACK_SIZE }; }
    7171static inline void ?{}(thread$ & this, struct cluster & cl, size_t stackSize )                          { this{ "Anonymous Thread", cl, 0p, stackSize }; }
    7272static inline void ?{}(thread$ & this, struct cluster & cl, void * storage, size_t storageSize )        { this{ "Anonymous Thread", cl, storage, storageSize }; }
    73 static inline void ?{}(thread$ & this, const char * const name)                                         { this{ name, *mainCluster, 0p, 65000 }; }
    74 static inline void ?{}(thread$ & this, const char * const name, struct cluster & cl )                   { this{ name, cl, 0p, 65000 }; }
     73static inline void ?{}(thread$ & this, const char * const name)                                         { this{ name, *mainCluster, 0p, DEFAULT_STACK_SIZE }; }
     74static inline void ?{}(thread$ & this, const char * const name, struct cluster & cl )                   { this{ name, cl, 0p, DEFAULT_STACK_SIZE }; }
    7575static inline void ?{}(thread$ & this, const char * const name, struct cluster & cl, size_t stackSize ) { this{ name, cl, 0p, stackSize }; }
    7676
  • tests/unified_locking/mutex_test.hfa

    r0ac728b r4233338b  
    1010        thread$ * id;
    1111        uint32_t sum;
     12        uint32_t cnt;
    1213};
    1314
     
    2728        {
    2829                uint32_t tsum = mo.sum;
     30                uint32_t cnt = mo.cnt;
    2931                mo.id = me;
    3032                yield(random(5));
    3133                value = ((uint32_t)random()) ^ ((uint32_t)me);
    3234                if(mo.id != me) sout | "Intruder!";
     35                mo.cnt = cnt + 1;
    3336                mo.sum = tsum + value;
    3437        }
     
    5457        uint32_t sum = -32;
    5558        mo.sum = -32;
     59        mo.cnt = 0;
    5660        processor p[2];
    5761        sout | "Starting";
     
    6367        }
    6468        sout | "Done!";
     69        if(mo.cnt != (13 * num_times)) sout | "Invalid cs count!" | mo.cnt | "vs "| (13 * num_times) | "(13 *" | num_times | ')';
    6570        if(sum == mo.sum) sout | "Match!";
    6671        else sout | "No Match!" | sum | "vs" | mo.sum;
Note: See TracChangeset for help on using the changeset viewer.