Changes in / [4233338b:0ac728b]


Ignore:
Files:
2 added
3 deleted
8 edited

Legend:

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

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

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

    r4233338b r0ac728b  
    142142extern void __disable_interrupts_hard();
    143143extern void __enable_interrupts_hard();
     144
     145static inline void __disable_interrupts_checked() {
     146        /* paranoid */ verify( __preemption_enabled() );
     147        disable_interrupts();
     148        /* paranoid */ verify( ! __preemption_enabled() );
     149}
     150
     151static inline void __enable_interrupts_checked( bool poll = true ) {
     152        /* paranoid */ verify( ! __preemption_enabled() );
     153        enable_interrupts( poll );
     154        /* paranoid */ verify( __preemption_enabled() );
     155}
    144156
    145157
     
    764776// Unconditionnaly wake a thread
    765777void __wake_proc(processor * this) {
    766         /* paranoid */ verify( ! __preemption_enabled() );
    767 
    768778        __cfadbg_print_safe(runtime_core, "Kernel : waking Processor %p\n", this);
    769779
    770         eventfd_t val;
    771         val = 1;
    772         eventfd_write( this->idle_fd, val );
    773 
    774         /* paranoid */ verify( ! __preemption_enabled() );
     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();
    775786}
    776787
  • libcfa/src/concurrency/kernel/startup.cfa

    r4233338b r0ac728b  
    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) );
    282281        __atomic_store_n(&mainProcessor->do_terminate, true, __ATOMIC_RELEASE);
    283         __wake_proc( mainProcessor );
    284282        __kernel_last_resume( __cfaabi_tls.this_processor );
    285283        mainThread->self_cor.state = Halted;
     
    405403
    406404        __cfaabi_tls.this_thread->curr_cor = dst;
    407         __stack_prepare( &dst->stack, DEFAULT_STACK_SIZE );
     405        __stack_prepare( &dst->stack, 65000 );
    408406        __cfactx_start(main, dst, this->runner, __cfactx_invoke_coroutine);
    409407
     
    566564extern size_t __page_size;
    567565void ^?{}(processor & this) with( this ){
    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();
     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);
    573570                __wake_proc( &this );
    574         __enable_interrupts_checked();
    575 
    576         wait( terminated );
    577         /* paranoid */ verify( active_processor() != &this);
     571
     572                wait( terminated );
     573                /* paranoid */ verify( active_processor() != &this);
     574        }
    578575
    579576        __destroy_pthread( kernel_thread, this.stack, 0p );
     
    724721        check( pthread_attr_init( &attr ), "pthread_attr_init" ); // initialize attribute
    725722
    726         size_t stacksize = DEFAULT_STACK_SIZE;
     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 );
    727727
    728728        void * stack;
     
    749749        #endif
    750750
     751
    751752        check( pthread_attr_setstack( &attr, stack, stacksize ), "pthread_attr_setstack" );
     753
    752754        check( pthread_create( pthread, &attr, start, arg ), "pthread_create" );
    753755        return stack;
  • libcfa/src/concurrency/kernel_private.hfa

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

    r4233338b r0ac728b  
    177177};
    178178
    179 static inline void ?{}(fast_lock & this) __attribute__((deprecated("use linear_backoff_then_block_lock instead")));
    180179static inline void ?{}(fast_lock & this) { this.owner = 0p; }
    181180
     
    185184}
    186185
    187 static inline void lock( fast_lock & this ) __attribute__((deprecated("use linear_backoff_then_block_lock instead"), artificial));
     186static inline void lock( fast_lock & this ) __attribute__((artificial));
    188187static inline void lock( fast_lock & this ) {
    189188        thread$ * thrd = active_thread();
     
    196195}
    197196
    198 static inline bool try_lock( fast_lock & this ) __attribute__((deprecated("use linear_backoff_then_block_lock instead"), artificial));
     197static inline bool try_lock( fast_lock & this ) __attribute__((artificial));
    199198static inline bool try_lock ( fast_lock & this ) {
    200199        thread$ * thrd = active_thread();
     
    203202}
    204203
    205 static inline thread$ * unlock( fast_lock & this ) __attribute__((deprecated("use linear_backoff_then_block_lock instead"), artificial));
     204static inline thread$ * unlock( fast_lock & this ) __attribute__((artificial));
    206205static inline thread$ * unlock( fast_lock & this ) {
    207206        /* paranoid */ verify(active_thread() == this.owner);
  • libcfa/src/concurrency/thread.hfa

    r4233338b r0ac728b  
    1010// Created On       : Tue Jan 17 12:27:26 2017
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Jan  6 16:40:16 2022
    13 // Update Count     : 7
     12// Last Modified On : Wed Dec  4 09:18:14 2019
     13// Update Count     : 6
    1414//
    1515
     
    6565void ^?{}(thread$ & this);
    6666
    67 static inline void ?{}(thread$ & this)                                                                  { this{ "Anonymous Thread", *mainCluster, 0p, DEFAULT_STACK_SIZE }; }
     67static inline void ?{}(thread$ & this)                                                                  { this{ "Anonymous Thread", *mainCluster, 0p, 65000 }; }
    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, DEFAULT_STACK_SIZE }; }
     70static inline void ?{}(thread$ & this, struct cluster & cl )                                            { this{ "Anonymous Thread", cl, 0p, 65000 }; }
    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, DEFAULT_STACK_SIZE }; }
    74 static inline void ?{}(thread$ & this, const char * const name, struct cluster & cl )                   { this{ name, cl, 0p, DEFAULT_STACK_SIZE }; }
     73static inline void ?{}(thread$ & this, const char * const name)                                         { this{ name, *mainCluster, 0p, 65000 }; }
     74static inline void ?{}(thread$ & this, const char * const name, struct cluster & cl )                   { this{ name, cl, 0p, 65000 }; }
    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

    r4233338b r0ac728b  
    1010        thread$ * id;
    1111        uint32_t sum;
    12         uint32_t cnt;
    1312};
    1413
     
    2827        {
    2928                uint32_t tsum = mo.sum;
    30                 uint32_t cnt = mo.cnt;
    3129                mo.id = me;
    3230                yield(random(5));
    3331                value = ((uint32_t)random()) ^ ((uint32_t)me);
    3432                if(mo.id != me) sout | "Intruder!";
    35                 mo.cnt = cnt + 1;
    3633                mo.sum = tsum + value;
    3734        }
     
    5754        uint32_t sum = -32;
    5855        mo.sum = -32;
    59         mo.cnt = 0;
    6056        processor p[2];
    6157        sout | "Starting";
     
    6763        }
    6864        sout | "Done!";
    69         if(mo.cnt != (13 * num_times)) sout | "Invalid cs count!" | mo.cnt | "vs "| (13 * num_times) | "(13 *" | num_times | ')';
    7065        if(sum == mo.sum) sout | "Match!";
    7166        else sout | "No Match!" | sum | "vs" | mo.sum;
Note: See TracChangeset for help on using the changeset viewer.