Ignore:
Timestamp:
Dec 17, 2020, 10:34:27 AM (3 years ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast-unique-expr, pthread-emulation, qualifiedEnum
Children:
852ae0ea
Parents:
72a3aff (diff), 28e88d7 (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

Location:
libcfa/src/concurrency
Files:
6 edited

Legend:

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

    r72a3aff r7a70fb2  
    1010// Created On       : Mon Nov 28 12:27:26 2016
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri Oct 23 23:05:24 2020
    13 // Update Count     : 22
     12// Last Modified On : Tue Dec 15 12:06:04 2020
     13// Update Count     : 23
    1414//
    1515
     
    8888static const size_t MinStackSize = 1000;
    8989extern size_t __page_size;                              // architecture pagesize HACK, should go in proper runtime singleton
     90extern int __map_prot;
    9091
    9192void __stack_prepare( __stack_info_t * this, size_t create_size );
     
    206207                __cfaabi_dbg_debug_do(
    207208                        storage = (char*)(storage) - __page_size;
    208                         if ( mprotect( storage, __page_size, PROT_READ | PROT_WRITE ) == -1 ) {
     209                        if ( mprotect( storage, __page_size, __map_prot ) == -1 ) {
    209210                                abort( "(coStack_t *)%p.^?{}() : internal error, mprotect failure, error(%d) %s.", &this, errno, strerror( errno ) );
    210211                        }
  • libcfa/src/concurrency/invoke.h

    r72a3aff r7a70fb2  
    189189                struct __monitor_group_t monitors;
    190190
     191                // used to put threads on user data structures
     192                struct {
     193                        struct $thread * next;
     194                        struct $thread * back;
     195                } seqable;
     196
    191197                struct {
    192198                        struct $thread * next;
     
    218224                }
    219225
     226                static inline $thread *& Back( $thread * this ) __attribute__((const)) {
     227                        return this->seqable.back;
     228                }
     229
     230                static inline $thread *& Next( $thread * this ) __attribute__((const)) {
     231                        return this->seqable.next;
     232                }
     233
     234                static inline bool listed( $thread * this ) {
     235                        return this->seqable.next != 0p;
     236                }
     237
    220238                static inline void ?{}(__monitor_group_t & this) {
    221239                        (this.data){0p};
  • libcfa/src/concurrency/kernel/startup.cfa

    r72a3aff r7a70fb2  
    117117}
    118118
    119 size_t __page_size = 0;
     119extern size_t __page_size;
    120120
    121121//-----------------------------------------------------------------------------
     
    161161        /* paranoid */ verify( ! __preemption_enabled() );
    162162        __cfadbg_print_safe(runtime_core, "Kernel : Starting\n");
    163 
    164         __page_size = sysconf( _SC_PAGESIZE );
    165163
    166164        __cfa_dbg_global_clusters.list{ __get };
     
    681679        #if CFA_PROCESSOR_USE_MMAP
    682680                stacksize = ceiling( stacksize, __page_size ) + __page_size;
    683                 stack = mmap(0p, stacksize, PROT_EXEC | PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, 0, 0);
     681                stack = mmap(0p, stacksize, __map_prot, MAP_PRIVATE | MAP_ANONYMOUS, 0, 0);
    684682                if(stack == ((void*)-1)) {
    685683                        abort( "pthread stack creation : internal error, mmap failure, error(%d) %s.", errno, strerror( errno ) );
  • libcfa/src/concurrency/locks.cfa

    r72a3aff r7a70fb2  
    2929
    3030        void ^?{}( info_thread(L) & this ){ }
     31
     32        info_thread(L) *& Back( info_thread(L) * this ) {
     33                return (info_thread(L) *)Back( (Seqable *)this );
     34        }
     35
     36        info_thread(L) *& Next( info_thread(L) * this ) {
     37                return (info_thread(L) *)Next( (Colable *)this );
     38        }
     39
     40        bool listed( info_thread(L) * this ) {
     41                return Next( (Colable *)this ) != 0p;
     42        }
    3143}
    3244
     
    5870                abort("A single acquisition lock holder attempted to reacquire the lock resulting in a deadlock.");
    5971        } else if ( owner != 0p && owner != active_thread() ) {
    60                 append( blocked_threads, active_thread() );
     72                addTail( blocked_threads, *active_thread() );
    6173                wait_count++;
    6274                unlock( lock );
     
    96108
    97109void pop_and_set_new_owner( blocking_lock & this ) with( this ) {
    98         $thread * t = pop_head( blocked_threads );
     110        $thread * t = &dropHead( blocked_threads );
    99111        owner = t;
    100112        recursion_count = ( t ? 1 : 0 );
     
    128140    lock( lock __cfaabi_dbg_ctx2 );
    129141        if ( owner != 0p ) {
    130                 append( blocked_threads, t );
     142                addTail( blocked_threads, *t );
    131143                wait_count++;
    132144                unlock( lock );
     
    257269                size_t recursion_count = 0;
    258270                if (i->lock) {
    259                         i->t->link.next = 1p;
    260271                        recursion_count = get_recursion_count(*i->lock);
    261272                        remove_( *i->lock );
  • libcfa/src/concurrency/locks.hfa

    r72a3aff r7a70fb2  
    4343        void ?{}( info_thread(L) & this, $thread * t, uintptr_t info );
    4444        void ^?{}( info_thread(L) & this );
     45
     46        info_thread(L) *& Back( info_thread(L) * this );
     47        info_thread(L) *& Next( info_thread(L) * this );
     48        bool listed( info_thread(L) * this );
    4549}
    4650
     
    6468
    6569        // List of blocked threads
    66         __queue_t( $thread ) blocked_threads;
     70        Sequence( $thread ) blocked_threads;
    6771
    6872        // Count of current blocked threads
  • libcfa/src/concurrency/thread.cfa

    r72a3aff r7a70fb2  
    4343                canary = 0x0D15EA5E0D15EA5Ep;
    4444        #endif
     45
     46        seqable.next = 0p;
     47        seqable.back = 0p;
    4548
    4649        node.next = 0p;
Note: See TracChangeset for help on using the changeset viewer.