Changeset d4afaac


Ignore:
Timestamp:
May 30, 2018, 1:34:51 PM (4 years ago)
Author:
Rob Schluntz <rschlunt@…>
Branches:
aaron-thesis, arm-eh, cleanup-dtors, deferred_resn, demangler, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, with_gc
Children:
cb7caf8
Parents:
3530f39a (diff), 6c7099a (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:/u/cforall/software/cfa/cfa-cc

Location:
src
Files:
2 added
1 deleted
11 edited

Legend:

Unmodified
Added
Removed
  • src/Concurrency/Keywords.cc

    r3530f39a rd4afaac  
    443443                bool first = false;
    444444                std::list<DeclarationWithType*> mutexArgs = findMutexArgs( decl, first );
    445                 if( mutexArgs.empty() ) return;
    446 
    447                 if( CodeGen::isConstructor(decl->name) && first ) SemanticError( decl, "constructors cannot have mutex parameters" );
    448 
    449445                bool isDtor = CodeGen::isDestructor( decl->name );
    450446
     447                // Is this function relevant to monitors
     448                if( mutexArgs.empty() ) {
     449                        // If this is the destructor for a monitor it must be mutex
     450                        if(isDtor) {
     451                                Type* ty = decl->get_functionType()->get_parameters().front()->get_type();
     452
     453                                // If it's a copy, it's not a mutex
     454                                ReferenceType* rty = dynamic_cast< ReferenceType * >( ty );
     455                                if( ! rty ) return;
     456
     457                                // If we are not pointing directly to a type, it's not a mutex
     458                                Type* base = rty->get_base();
     459                                if( dynamic_cast< ReferenceType * >( base ) ) return;
     460                                if( dynamic_cast< PointerType * >( base ) ) return;
     461
     462                                // Check if its a struct
     463                                StructInstType * baseStruct = dynamic_cast< StructInstType * >( base );
     464                                if( !baseStruct ) return;
     465
     466                                // Check if its a monitor
     467                                if(baseStruct->baseStruct->is_monitor() || baseStruct->baseStruct->is_thread())
     468                                        SemanticError( decl, "destructors for structures declared as \"monitor\" must use mutex parameters\n" );
     469                        }
     470                        return;
     471                }
     472
     473                // Monitors can't be constructed with mutual exclusion
     474                if( CodeGen::isConstructor(decl->name) && !first ) SemanticError( decl, "constructors cannot have mutex parameters" );
     475
     476                // It makes no sense to have multiple mutex parameters for the destructor
    451477                if( isDtor && mutexArgs.size() != 1 ) SemanticError( decl, "destructors can only have 1 mutex argument" );
    452478
     479                // Make sure all the mutex arguments are monitors
    453480                for(auto arg : mutexArgs) {
    454481                        validate( arg );
    455482                }
    456483
     484                // Check if we need to instrument the body
    457485                CompoundStmt* body = decl->get_statements();
    458486                if( ! body ) return;
    459487
     488                // Do we have the required headers
    460489                if( !monitor_decl || !guard_decl || !dtor_guard_decl )
    461                         SemanticError( decl, "mutex keyword requires monitors to be in scope, add #include <monitor>" );
    462 
     490                        SemanticError( decl, "mutex keyword requires monitors to be in scope, add #include <monitor>\n" );
     491
     492                // Instrument the body
    463493                if( isDtor ) {
    464494                        addDtorStatments( decl, body, mutexArgs );
  • src/benchmark/Makefile.am

    r3530f39a rd4afaac  
    277277
    278278compile-io$(EXEEXT):
    279         @${CC} -quiet -fsyntax-only -w ../tests/io.c                                    @CFA_FLAGS@ ${AM_CFLAGS} ${CFLAGS} ${ccflags}
     279        @${CC} -quiet -fsyntax-only -w ../tests/io1.c                           @CFA_FLAGS@ ${AM_CFLAGS} ${CFLAGS} ${ccflags}
    280280
    281281compile-monitor$(EXEEXT):
    282         @${CC} -quiet -fsyntax-only -w ../tests/concurrent/monitor.c            @CFA_FLAGS@ ${AM_CFLAGS} ${CFLAGS} ${ccflags}
     282        @${CC} -quiet -fsyntax-only -w ../tests/concurrent/monitor.c    @CFA_FLAGS@ ${AM_CFLAGS} ${CFLAGS} ${ccflags}
    283283
    284284compile-operators$(EXEEXT):
     
    289289
    290290compile-typeof$(EXEEXT):
    291         @${CC} -quiet -fsyntax-only -w ../tests/typeof.c                                @CFA_FLAGS@ ${AM_CFLAGS} ${CFLAGS} ${ccflags}
    292 
     291        @${CC} -quiet -fsyntax-only -w ../tests/typeof.c                        @CFA_FLAGS@ ${AM_CFLAGS} ${CFLAGS} ${ccflags}
     292
  • src/libcfa/Makefile.am

    r3530f39a rd4afaac  
    5151# not all platforms support concurrency, add option do disable it
    5252if BUILD_CONCURRENCY
    53 headers += concurrency/coroutine concurrency/thread concurrency/kernel concurrency/monitor
     53headers += concurrency/coroutine concurrency/thread concurrency/kernel concurrency/monitor concurrency/mutex
    5454endif
    5555
  • src/libcfa/Makefile.in

    r3530f39a rd4afaac  
    9797
    9898# not all platforms support concurrency, add option do disable it
    99 @BUILD_CONCURRENCY_TRUE@am__append_3 = concurrency/coroutine concurrency/thread concurrency/kernel concurrency/monitor
     99@BUILD_CONCURRENCY_TRUE@am__append_3 = concurrency/coroutine concurrency/thread concurrency/kernel concurrency/monitor concurrency/mutex
    100100
    101101# not all platforms support concurrency, add option do disable it
     
    153153        containers/pair.c containers/result.c containers/vector.c \
    154154        concurrency/coroutine.c concurrency/thread.c \
    155         concurrency/kernel.c concurrency/monitor.c assert.c \
    156         exception.c virtual.c concurrency/CtxSwitch-@MACHINE_TYPE@.S \
    157         concurrency/alarm.c concurrency/invoke.c \
    158         concurrency/preemption.c
     155        concurrency/kernel.c concurrency/monitor.c concurrency/mutex.c \
     156        assert.c exception.c virtual.c \
     157        concurrency/CtxSwitch-@MACHINE_TYPE@.S concurrency/alarm.c \
     158        concurrency/invoke.c concurrency/preemption.c
    159159am__dirstamp = $(am__leading_dot)dirstamp
    160160@BUILD_CONCURRENCY_TRUE@am__objects_1 = concurrency/libcfa_d_a-coroutine.$(OBJEXT) \
    161161@BUILD_CONCURRENCY_TRUE@        concurrency/libcfa_d_a-thread.$(OBJEXT) \
    162162@BUILD_CONCURRENCY_TRUE@        concurrency/libcfa_d_a-kernel.$(OBJEXT) \
    163 @BUILD_CONCURRENCY_TRUE@        concurrency/libcfa_d_a-monitor.$(OBJEXT)
     163@BUILD_CONCURRENCY_TRUE@        concurrency/libcfa_d_a-monitor.$(OBJEXT) \
     164@BUILD_CONCURRENCY_TRUE@        concurrency/libcfa_d_a-mutex.$(OBJEXT)
    164165am__objects_2 = libcfa_d_a-fstream.$(OBJEXT) \
    165166        libcfa_d_a-iostream.$(OBJEXT) libcfa_d_a-iterator.$(OBJEXT) \
     
    188189        containers/result.c containers/vector.c \
    189190        concurrency/coroutine.c concurrency/thread.c \
    190         concurrency/kernel.c concurrency/monitor.c assert.c \
    191         exception.c virtual.c concurrency/CtxSwitch-@MACHINE_TYPE@.S \
    192         concurrency/alarm.c concurrency/invoke.c \
    193         concurrency/preemption.c
     191        concurrency/kernel.c concurrency/monitor.c concurrency/mutex.c \
     192        assert.c exception.c virtual.c \
     193        concurrency/CtxSwitch-@MACHINE_TYPE@.S concurrency/alarm.c \
     194        concurrency/invoke.c concurrency/preemption.c
    194195@BUILD_CONCURRENCY_TRUE@am__objects_5 = concurrency/libcfa_a-coroutine.$(OBJEXT) \
    195196@BUILD_CONCURRENCY_TRUE@        concurrency/libcfa_a-thread.$(OBJEXT) \
    196197@BUILD_CONCURRENCY_TRUE@        concurrency/libcfa_a-kernel.$(OBJEXT) \
    197 @BUILD_CONCURRENCY_TRUE@        concurrency/libcfa_a-monitor.$(OBJEXT)
     198@BUILD_CONCURRENCY_TRUE@        concurrency/libcfa_a-monitor.$(OBJEXT) \
     199@BUILD_CONCURRENCY_TRUE@        concurrency/libcfa_a-mutex.$(OBJEXT)
    198200am__objects_6 = libcfa_a-fstream.$(OBJEXT) libcfa_a-iostream.$(OBJEXT) \
    199201        libcfa_a-iterator.$(OBJEXT) libcfa_a-limits.$(OBJEXT) \
     
    264266        containers/result containers/vector concurrency/coroutine \
    265267        concurrency/thread concurrency/kernel concurrency/monitor \
    266         ${shell find stdhdr -type f -printf "%p "} math gmp time_t.h \
    267         clock bits/align.h bits/containers.h bits/defs.h bits/debug.h \
    268         bits/locks.h concurrency/invoke.h
     268        concurrency/mutex ${shell find stdhdr -type f -printf "%p "} \
     269        math gmp time_t.h clock bits/align.h bits/containers.h \
     270        bits/defs.h bits/debug.h bits/locks.h concurrency/invoke.h
    269271HEADERS = $(nobase_cfa_include_HEADERS)
    270272am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP)
     
    548550concurrency/libcfa_d_a-monitor.$(OBJEXT): concurrency/$(am__dirstamp) \
    549551        concurrency/$(DEPDIR)/$(am__dirstamp)
     552concurrency/libcfa_d_a-mutex.$(OBJEXT): concurrency/$(am__dirstamp) \
     553        concurrency/$(DEPDIR)/$(am__dirstamp)
    550554concurrency/CtxSwitch-@MACHINE_TYPE@.$(OBJEXT):  \
    551555        concurrency/$(am__dirstamp) \
     
    580584        concurrency/$(DEPDIR)/$(am__dirstamp)
    581585concurrency/libcfa_a-monitor.$(OBJEXT): concurrency/$(am__dirstamp) \
     586        concurrency/$(DEPDIR)/$(am__dirstamp)
     587concurrency/libcfa_a-mutex.$(OBJEXT): concurrency/$(am__dirstamp) \
    582588        concurrency/$(DEPDIR)/$(am__dirstamp)
    583589concurrency/libcfa_a-alarm.$(OBJEXT): concurrency/$(am__dirstamp) \
     
    635641@AMDEP_TRUE@@am__include@ @am__quote@concurrency/$(DEPDIR)/libcfa_a-kernel.Po@am__quote@
    636642@AMDEP_TRUE@@am__include@ @am__quote@concurrency/$(DEPDIR)/libcfa_a-monitor.Po@am__quote@
     643@AMDEP_TRUE@@am__include@ @am__quote@concurrency/$(DEPDIR)/libcfa_a-mutex.Po@am__quote@
    637644@AMDEP_TRUE@@am__include@ @am__quote@concurrency/$(DEPDIR)/libcfa_a-preemption.Po@am__quote@
    638645@AMDEP_TRUE@@am__include@ @am__quote@concurrency/$(DEPDIR)/libcfa_a-thread.Po@am__quote@
     
    642649@AMDEP_TRUE@@am__include@ @am__quote@concurrency/$(DEPDIR)/libcfa_d_a-kernel.Po@am__quote@
    643650@AMDEP_TRUE@@am__include@ @am__quote@concurrency/$(DEPDIR)/libcfa_d_a-monitor.Po@am__quote@
     651@AMDEP_TRUE@@am__include@ @am__quote@concurrency/$(DEPDIR)/libcfa_d_a-mutex.Po@am__quote@
    644652@AMDEP_TRUE@@am__include@ @am__quote@concurrency/$(DEPDIR)/libcfa_d_a-preemption.Po@am__quote@
    645653@AMDEP_TRUE@@am__include@ @am__quote@concurrency/$(DEPDIR)/libcfa_d_a-thread.Po@am__quote@
     
    930938@am__fastdepCC_FALSE@   $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_d_a_CFLAGS) $(CFLAGS) -c -o concurrency/libcfa_d_a-monitor.obj `if test -f 'concurrency/monitor.c'; then $(CYGPATH_W) 'concurrency/monitor.c'; else $(CYGPATH_W) '$(srcdir)/concurrency/monitor.c'; fi`
    931939
     940concurrency/libcfa_d_a-mutex.o: concurrency/mutex.c
     941@am__fastdepCC_TRUE@    $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_d_a_CFLAGS) $(CFLAGS) -MT concurrency/libcfa_d_a-mutex.o -MD -MP -MF concurrency/$(DEPDIR)/libcfa_d_a-mutex.Tpo -c -o concurrency/libcfa_d_a-mutex.o `test -f 'concurrency/mutex.c' || echo '$(srcdir)/'`concurrency/mutex.c
     942@am__fastdepCC_TRUE@    $(AM_V_at)$(am__mv) concurrency/$(DEPDIR)/libcfa_d_a-mutex.Tpo concurrency/$(DEPDIR)/libcfa_d_a-mutex.Po
     943@AMDEP_TRUE@@am__fastdepCC_FALSE@       $(AM_V_CC)source='concurrency/mutex.c' object='concurrency/libcfa_d_a-mutex.o' libtool=no @AMDEPBACKSLASH@
     944@AMDEP_TRUE@@am__fastdepCC_FALSE@       DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
     945@am__fastdepCC_FALSE@   $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_d_a_CFLAGS) $(CFLAGS) -c -o concurrency/libcfa_d_a-mutex.o `test -f 'concurrency/mutex.c' || echo '$(srcdir)/'`concurrency/mutex.c
     946
     947concurrency/libcfa_d_a-mutex.obj: concurrency/mutex.c
     948@am__fastdepCC_TRUE@    $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_d_a_CFLAGS) $(CFLAGS) -MT concurrency/libcfa_d_a-mutex.obj -MD -MP -MF concurrency/$(DEPDIR)/libcfa_d_a-mutex.Tpo -c -o concurrency/libcfa_d_a-mutex.obj `if test -f 'concurrency/mutex.c'; then $(CYGPATH_W) 'concurrency/mutex.c'; else $(CYGPATH_W) '$(srcdir)/concurrency/mutex.c'; fi`
     949@am__fastdepCC_TRUE@    $(AM_V_at)$(am__mv) concurrency/$(DEPDIR)/libcfa_d_a-mutex.Tpo concurrency/$(DEPDIR)/libcfa_d_a-mutex.Po
     950@AMDEP_TRUE@@am__fastdepCC_FALSE@       $(AM_V_CC)source='concurrency/mutex.c' object='concurrency/libcfa_d_a-mutex.obj' libtool=no @AMDEPBACKSLASH@
     951@AMDEP_TRUE@@am__fastdepCC_FALSE@       DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
     952@am__fastdepCC_FALSE@   $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_d_a_CFLAGS) $(CFLAGS) -c -o concurrency/libcfa_d_a-mutex.obj `if test -f 'concurrency/mutex.c'; then $(CYGPATH_W) 'concurrency/mutex.c'; else $(CYGPATH_W) '$(srcdir)/concurrency/mutex.c'; fi`
     953
    932954libcfa_d_a-assert.o: assert.c
    933955@am__fastdepCC_TRUE@    $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_d_a_CFLAGS) $(CFLAGS) -MT libcfa_d_a-assert.o -MD -MP -MF $(DEPDIR)/libcfa_d_a-assert.Tpo -c -o libcfa_d_a-assert.o `test -f 'assert.c' || echo '$(srcdir)/'`assert.c
     
    12371259@AMDEP_TRUE@@am__fastdepCC_FALSE@       DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
    12381260@am__fastdepCC_FALSE@   $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -c -o concurrency/libcfa_a-monitor.obj `if test -f 'concurrency/monitor.c'; then $(CYGPATH_W) 'concurrency/monitor.c'; else $(CYGPATH_W) '$(srcdir)/concurrency/monitor.c'; fi`
     1261
     1262concurrency/libcfa_a-mutex.o: concurrency/mutex.c
     1263@am__fastdepCC_TRUE@    $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -MT concurrency/libcfa_a-mutex.o -MD -MP -MF concurrency/$(DEPDIR)/libcfa_a-mutex.Tpo -c -o concurrency/libcfa_a-mutex.o `test -f 'concurrency/mutex.c' || echo '$(srcdir)/'`concurrency/mutex.c
     1264@am__fastdepCC_TRUE@    $(AM_V_at)$(am__mv) concurrency/$(DEPDIR)/libcfa_a-mutex.Tpo concurrency/$(DEPDIR)/libcfa_a-mutex.Po
     1265@AMDEP_TRUE@@am__fastdepCC_FALSE@       $(AM_V_CC)source='concurrency/mutex.c' object='concurrency/libcfa_a-mutex.o' libtool=no @AMDEPBACKSLASH@
     1266@AMDEP_TRUE@@am__fastdepCC_FALSE@       DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
     1267@am__fastdepCC_FALSE@   $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -c -o concurrency/libcfa_a-mutex.o `test -f 'concurrency/mutex.c' || echo '$(srcdir)/'`concurrency/mutex.c
     1268
     1269concurrency/libcfa_a-mutex.obj: concurrency/mutex.c
     1270@am__fastdepCC_TRUE@    $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -MT concurrency/libcfa_a-mutex.obj -MD -MP -MF concurrency/$(DEPDIR)/libcfa_a-mutex.Tpo -c -o concurrency/libcfa_a-mutex.obj `if test -f 'concurrency/mutex.c'; then $(CYGPATH_W) 'concurrency/mutex.c'; else $(CYGPATH_W) '$(srcdir)/concurrency/mutex.c'; fi`
     1271@am__fastdepCC_TRUE@    $(AM_V_at)$(am__mv) concurrency/$(DEPDIR)/libcfa_a-mutex.Tpo concurrency/$(DEPDIR)/libcfa_a-mutex.Po
     1272@AMDEP_TRUE@@am__fastdepCC_FALSE@       $(AM_V_CC)source='concurrency/mutex.c' object='concurrency/libcfa_a-mutex.obj' libtool=no @AMDEPBACKSLASH@
     1273@AMDEP_TRUE@@am__fastdepCC_FALSE@       DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
     1274@am__fastdepCC_FALSE@   $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -c -o concurrency/libcfa_a-mutex.obj `if test -f 'concurrency/mutex.c'; then $(CYGPATH_W) 'concurrency/mutex.c'; else $(CYGPATH_W) '$(srcdir)/concurrency/mutex.c'; fi`
    12391275
    12401276libcfa_a-assert.o: assert.c
  • src/libcfa/bits/containers.h

    r3530f39a rd4afaac  
    183183                verify( *tail == NULL );
    184184                return val;
     185        }
     186
     187        forall(dtype T | is_node(T))
     188        static inline bool ?!=?( __queue(T) & this, zero_t zero ) with( this ) {
     189                return head != 0;
    185190        }
    186191#endif
  • src/libcfa/concurrency/kernel

    r3530f39a rd4afaac  
    4343extern struct cluster * mainCluster;
    4444
    45 enum FinishOpCode { No_Action, Release, Schedule, Release_Schedule, Release_Multi, Release_Multi_Schedule };
     45enum FinishOpCode { No_Action, Release, Schedule, Release_Schedule, Release_Multi, Release_Multi_Schedule, Callback };
     46
     47typedef void (*__finish_callback_fptr_t)(void);
    4648
    4749//TODO use union, many of these fields are mutually exclusive (i.e. MULTI vs NOMULTI)
    4850struct FinishAction {
    4951        FinishOpCode action_code;
     52        /*
     53        // Union of possible actions
     54        union {
     55                // Option 1 : locks and threads
     56                struct {
     57                        // 1 thread or N thread
     58                        union {
     59                                thread_desc * thrd;
     60                                struct {
     61                                        thread_desc ** thrds;
     62                                        unsigned short thrd_count;
     63                                };
     64                        };
     65                        // 1 lock or N lock
     66                        union {
     67                                __spinlock_t * lock;
     68                                struct {
     69                                        __spinlock_t ** locks;
     70                                        unsigned short lock_count;
     71                                };
     72                        };
     73                };
     74                // Option 2 : action pointer
     75                __finish_callback_fptr_t callback;
     76        };
     77        /*/
    5078        thread_desc * thrd;
     79        thread_desc ** thrds;
     80        unsigned short thrd_count;
    5181        __spinlock_t * lock;
    5282        __spinlock_t ** locks;
    5383        unsigned short lock_count;
    54         thread_desc ** thrds;
    55         unsigned short thrd_count;
     84        __finish_callback_fptr_t callback;
     85        //*/
    5686};
    5787static inline void ?{}(FinishAction & this) {
  • src/libcfa/concurrency/kernel.c

    r3530f39a rd4afaac  
    4949thread_desc * mainThread;
    5050
    51 struct { __dllist_t(cluster    ) list; __spinlock_t lock; } global_clusters;
     51struct { __dllist_t(cluster) list; __spinlock_t lock; } global_clusters;
    5252
    5353//-----------------------------------------------------------------------------
     
    257257// its final actions must be executed from the kernel
    258258void finishRunning(processor * this) with( this->finish ) {
    259         if( action_code == Release ) {
    260                 verify( ! kernelTLS.preemption_state.enabled );
     259        verify( ! kernelTLS.preemption_state.enabled );
     260        choose( action_code ) {
     261        case No_Action:
     262                break;
     263        case Release:
    261264                unlock( *lock );
    262         }
    263         else if( action_code == Schedule ) {
     265        case Schedule:
    264266                ScheduleThread( thrd );
    265         }
    266         else if( action_code == Release_Schedule ) {
    267                 verify( ! kernelTLS.preemption_state.enabled );
     267        case Release_Schedule:
    268268                unlock( *lock );
    269269                ScheduleThread( thrd );
    270         }
    271         else if( action_code == Release_Multi ) {
    272                 verify( ! kernelTLS.preemption_state.enabled );
     270        case Release_Multi:
    273271                for(int i = 0; i < lock_count; i++) {
    274272                        unlock( *locks[i] );
    275273                }
    276         }
    277         else if( action_code == Release_Multi_Schedule ) {
     274        case Release_Multi_Schedule:
    278275                for(int i = 0; i < lock_count; i++) {
    279276                        unlock( *locks[i] );
     
    282279                        ScheduleThread( thrds[i] );
    283280                }
    284         }
    285         else {
    286                 assert(action_code == No_Action);
     281        case Callback:
     282                callback();
     283        default:
     284                abort("KERNEL ERROR: Unexpected action to run after thread");
    287285        }
    288286}
     
    497495}
    498496
     497void BlockInternal(__finish_callback_fptr_t callback) {
     498        disable_interrupts();
     499        with( *kernelTLS.this_processor ) {
     500                finish.action_code = Callback;
     501                finish.callback    = callback;
     502        }
     503
     504        verify( ! kernelTLS.preemption_state.enabled );
     505        returnToKernel();
     506        verify( ! kernelTLS.preemption_state.enabled );
     507
     508        enable_interrupts( __cfaabi_dbg_ctx );
     509}
     510
    499511// KERNEL ONLY
    500512void LeaveThread(__spinlock_t * lock, thread_desc * thrd) {
  • src/libcfa/concurrency/kernel_private.h

    r3530f39a rd4afaac  
    4848void BlockInternal(__spinlock_t * locks [], unsigned short count);
    4949void BlockInternal(__spinlock_t * locks [], unsigned short count, thread_desc * thrds [], unsigned short thrd_count);
     50void BlockInternal(__finish_callback_fptr_t callback);
    5051void LeaveThread(__spinlock_t * lock, thread_desc * thrd);
    5152
  • src/libcfa/concurrency/monitor.c

    r3530f39a rd4afaac  
    297297        this.count = count;
    298298
    299         // Sort monitors based on address -> TODO use a sort specialized for small numbers
     299        // Sort monitors based on address
    300300        __libcfa_small_sort(this.m, count);
    301301
  • src/tests/concurrent/signal/block.c

    r3530f39a rd4afaac  
    4040}
    4141
    42 void ^?{} ( global_data_t & this ) {}
     42void ^?{} ( global_data_t & mutex this ) {}
    4343
    4444global_data_t globalA, globalB;
  • src/tests/concurrent/signal/disjoint.c

    r3530f39a rd4afaac  
    2626monitor global_data_t;
    2727void ?{}( global_data_t & this );
    28 void ^?{} ( global_data_t & this );
     28void ^?{} ( global_data_t & mutex this );
    2929
    3030monitor global_data_t {
     
    4242}
    4343
    44 void ^?{} ( global_data_t & this ) {}
     44void ^?{} ( global_data_t & mutex this ) {}
    4545
    4646//------------------------------------------------------------------------------
Note: See TracChangeset for help on using the changeset viewer.