Changeset 94b1022a for src/libcfa
- Timestamp:
- May 30, 2018, 9:28:18 PM (8 years ago)
- 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, with_gc
- Children:
- bd946e4
- Parents:
- 35718a9 (diff), ae32d96 (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. - Location:
- src/libcfa
- Files:
-
- 2 added
- 8 edited
-
Makefile.am (modified) (1 diff)
-
Makefile.in (modified) (10 diffs)
-
bits/containers.h (modified) (2 diffs)
-
concurrency/kernel (modified) (3 diffs)
-
concurrency/kernel.c (modified) (9 diffs)
-
concurrency/kernel_private.h (modified) (2 diffs)
-
concurrency/monitor.c (modified) (1 diff)
-
concurrency/mutex (added)
-
concurrency/mutex.c (added)
-
concurrency/preemption.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
src/libcfa/Makefile.am
r35718a9 r94b1022a 51 51 # not all platforms support concurrency, add option do disable it 52 52 if BUILD_CONCURRENCY 53 headers += concurrency/coroutine concurrency/thread concurrency/kernel concurrency/monitor 53 headers += concurrency/coroutine concurrency/thread concurrency/kernel concurrency/monitor concurrency/mutex 54 54 endif 55 55 -
src/libcfa/Makefile.in
r35718a9 r94b1022a 97 97 98 98 # 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 100 100 101 101 # not all platforms support concurrency, add option do disable it … … 153 153 containers/pair.c containers/result.c containers/vector.c \ 154 154 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.c155 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 159 159 am__dirstamp = $(am__leading_dot)dirstamp 160 160 @BUILD_CONCURRENCY_TRUE@am__objects_1 = concurrency/libcfa_d_a-coroutine.$(OBJEXT) \ 161 161 @BUILD_CONCURRENCY_TRUE@ concurrency/libcfa_d_a-thread.$(OBJEXT) \ 162 162 @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) 164 165 am__objects_2 = libcfa_d_a-fstream.$(OBJEXT) \ 165 166 libcfa_d_a-iostream.$(OBJEXT) libcfa_d_a-iterator.$(OBJEXT) \ … … 188 189 containers/result.c containers/vector.c \ 189 190 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.c191 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 194 195 @BUILD_CONCURRENCY_TRUE@am__objects_5 = concurrency/libcfa_a-coroutine.$(OBJEXT) \ 195 196 @BUILD_CONCURRENCY_TRUE@ concurrency/libcfa_a-thread.$(OBJEXT) \ 196 197 @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) 198 200 am__objects_6 = libcfa_a-fstream.$(OBJEXT) libcfa_a-iostream.$(OBJEXT) \ 199 201 libcfa_a-iterator.$(OBJEXT) libcfa_a-limits.$(OBJEXT) \ … … 264 266 containers/result containers/vector concurrency/coroutine \ 265 267 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.h268 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 269 271 HEADERS = $(nobase_cfa_include_HEADERS) 270 272 am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) … … 548 550 concurrency/libcfa_d_a-monitor.$(OBJEXT): concurrency/$(am__dirstamp) \ 549 551 concurrency/$(DEPDIR)/$(am__dirstamp) 552 concurrency/libcfa_d_a-mutex.$(OBJEXT): concurrency/$(am__dirstamp) \ 553 concurrency/$(DEPDIR)/$(am__dirstamp) 550 554 concurrency/CtxSwitch-@MACHINE_TYPE@.$(OBJEXT): \ 551 555 concurrency/$(am__dirstamp) \ … … 580 584 concurrency/$(DEPDIR)/$(am__dirstamp) 581 585 concurrency/libcfa_a-monitor.$(OBJEXT): concurrency/$(am__dirstamp) \ 586 concurrency/$(DEPDIR)/$(am__dirstamp) 587 concurrency/libcfa_a-mutex.$(OBJEXT): concurrency/$(am__dirstamp) \ 582 588 concurrency/$(DEPDIR)/$(am__dirstamp) 583 589 concurrency/libcfa_a-alarm.$(OBJEXT): concurrency/$(am__dirstamp) \ … … 635 641 @AMDEP_TRUE@@am__include@ @am__quote@concurrency/$(DEPDIR)/libcfa_a-kernel.Po@am__quote@ 636 642 @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@ 637 644 @AMDEP_TRUE@@am__include@ @am__quote@concurrency/$(DEPDIR)/libcfa_a-preemption.Po@am__quote@ 638 645 @AMDEP_TRUE@@am__include@ @am__quote@concurrency/$(DEPDIR)/libcfa_a-thread.Po@am__quote@ … … 642 649 @AMDEP_TRUE@@am__include@ @am__quote@concurrency/$(DEPDIR)/libcfa_d_a-kernel.Po@am__quote@ 643 650 @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@ 644 652 @AMDEP_TRUE@@am__include@ @am__quote@concurrency/$(DEPDIR)/libcfa_d_a-preemption.Po@am__quote@ 645 653 @AMDEP_TRUE@@am__include@ @am__quote@concurrency/$(DEPDIR)/libcfa_d_a-thread.Po@am__quote@ … … 930 938 @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` 931 939 940 concurrency/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 947 concurrency/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 932 954 libcfa_d_a-assert.o: assert.c 933 955 @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 … … 1237 1259 @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ 1238 1260 @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 1262 concurrency/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 1269 concurrency/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` 1239 1275 1240 1276 libcfa_a-assert.o: assert.c -
src/libcfa/bits/containers.h
r35718a9 r94b1022a 183 183 verify( *tail == NULL ); 184 184 return val; 185 } 186 187 forall(dtype T | is_node(T)) 188 static inline bool ?!=?( __queue(T) & this, zero_t zero ) { 189 return this.head != 0; 185 190 } 186 191 #endif … … 261 266 __get( node ).prev = NULL; 262 267 } 268 269 forall(dtype T | sized(T)) 270 static inline bool ?!=?( __dllist(T) & this, zero_t zero ) { 271 return this.head != 0; 272 } 263 273 #undef next 264 274 #undef prev -
src/libcfa/concurrency/kernel
r35718a9 r94b1022a 23 23 extern "C" { 24 24 #include <pthread.h> 25 #include <semaphore.h> 25 26 } 26 27 … … 43 44 extern struct cluster * mainCluster; 44 45 45 enum FinishOpCode { No_Action, Release, Schedule, Release_Schedule, Release_Multi, Release_Multi_Schedule }; 46 enum FinishOpCode { No_Action, Release, Schedule, Release_Schedule, Release_Multi, Release_Multi_Schedule, Callback }; 47 48 typedef void (*__finish_callback_fptr_t)(void); 46 49 47 50 //TODO use union, many of these fields are mutually exclusive (i.e. MULTI vs NOMULTI) 48 51 struct FinishAction { 49 52 FinishOpCode action_code; 53 /* 54 // Union of possible actions 55 union { 56 // Option 1 : locks and threads 57 struct { 58 // 1 thread or N thread 59 union { 60 thread_desc * thrd; 61 struct { 62 thread_desc ** thrds; 63 unsigned short thrd_count; 64 }; 65 }; 66 // 1 lock or N lock 67 union { 68 __spinlock_t * lock; 69 struct { 70 __spinlock_t ** locks; 71 unsigned short lock_count; 72 }; 73 }; 74 }; 75 // Option 2 : action pointer 76 __finish_callback_fptr_t callback; 77 }; 78 /*/ 50 79 thread_desc * thrd; 80 thread_desc ** thrds; 81 unsigned short thrd_count; 51 82 __spinlock_t * lock; 52 83 __spinlock_t ** locks; 53 84 unsigned short lock_count; 54 thread_desc ** thrds;55 unsigned short thrd_count;85 __finish_callback_fptr_t callback; 86 //*/ 56 87 }; 57 88 static inline void ?{}(FinishAction & this) { … … 101 132 102 133 // Idle lock 134 sem_t idleLock; 103 135 104 136 // Link lists fields -
src/libcfa/concurrency/kernel.c
r35718a9 r94b1022a 49 49 thread_desc * mainThread; 50 50 51 struct { __dllist_t(cluster ) list; __spinlock_t lock; } global_clusters;51 struct { __dllist_t(cluster) list; __spinlock_t lock; } global_clusters; 52 52 53 53 //----------------------------------------------------------------------------- … … 143 143 runner.proc = &this; 144 144 145 sem_init(&idleLock, 0, 0); 146 145 147 start( &this ); 146 148 } … … 156 158 pthread_join( kernel_thread, NULL ); 157 159 } 160 161 sem_destroy(&idleLock); 158 162 } 159 163 … … 257 261 // its final actions must be executed from the kernel 258 262 void finishRunning(processor * this) with( this->finish ) { 259 if( action_code == Release ) { 260 verify( ! kernelTLS.preemption_state.enabled ); 263 verify( ! kernelTLS.preemption_state.enabled ); 264 choose( action_code ) { 265 case No_Action: 266 break; 267 case Release: 261 268 unlock( *lock ); 262 } 263 else if( action_code == Schedule ) { 269 case Schedule: 264 270 ScheduleThread( thrd ); 265 } 266 else if( action_code == Release_Schedule ) { 267 verify( ! kernelTLS.preemption_state.enabled ); 271 case Release_Schedule: 268 272 unlock( *lock ); 269 273 ScheduleThread( thrd ); 270 } 271 else if( action_code == Release_Multi ) { 272 verify( ! kernelTLS.preemption_state.enabled ); 274 case Release_Multi: 273 275 for(int i = 0; i < lock_count; i++) { 274 276 unlock( *locks[i] ); 275 277 } 276 } 277 else if( action_code == Release_Multi_Schedule ) { 278 case Release_Multi_Schedule: 278 279 for(int i = 0; i < lock_count; i++) { 279 280 unlock( *locks[i] ); … … 282 283 ScheduleThread( thrds[i] ); 283 284 } 284 } 285 else { 286 assert(action_code == No_Action); 285 case Callback: 286 callback(); 287 default: 288 abort("KERNEL ERROR: Unexpected action to run after thread"); 287 289 } 288 290 } … … 291 293 // TODO : find some strategy to put cores to sleep after some time 292 294 void spin(processor * this, unsigned int * spin_count) { 293 (*spin_count)++; 295 // (*spin_count)++; 296 halt(this); 294 297 } 295 298 … … 396 399 with( *thrd->curr_cluster ) { 397 400 lock ( ready_queue_lock __cfaabi_dbg_ctx2 ); 401 bool was_empty = !(ready_queue != 0); 398 402 append( ready_queue, thrd ); 399 403 unlock( ready_queue_lock ); 404 405 if( was_empty ) { 406 lock (proc_list_lock __cfaabi_dbg_ctx2); 407 if(idles) { 408 wake(idles.head); 409 } 410 unlock (proc_list_lock); 411 } 400 412 } 401 413 … … 497 509 } 498 510 511 void BlockInternal(__finish_callback_fptr_t callback) { 512 disable_interrupts(); 513 with( *kernelTLS.this_processor ) { 514 finish.action_code = Callback; 515 finish.callback = callback; 516 } 517 518 verify( ! kernelTLS.preemption_state.enabled ); 519 returnToKernel(); 520 verify( ! kernelTLS.preemption_state.enabled ); 521 522 enable_interrupts( __cfaabi_dbg_ctx ); 523 } 524 499 525 // KERNEL ONLY 500 526 void LeaveThread(__spinlock_t * lock, thread_desc * thrd) { … … 627 653 //============================================================================================= 628 654 629 // void halt(processor * this) with( this ) { 630 // pthread_mutex_lock( &idle.lock ); 631 632 633 634 // // SKULLDUGGERY: Even if spurious wake-up is a thing 635 // // spuriously waking up a kernel thread is not a big deal 636 // // if it is very rare. 637 // pthread_cond_wait( &idle.cond, &idle.lock); 638 // pthread_mutex_unlock( &idle.lock ); 639 // } 640 641 // void wake(processor * this) with( this ) { 642 // pthread_mutex_lock (&idle.lock); 643 // pthread_cond_signal (&idle.cond); 644 // pthread_mutex_unlock(&idle.lock); 645 // } 655 void halt(processor * this) with( *this ) { 656 with( *cltr ) { 657 lock (proc_list_lock __cfaabi_dbg_ctx2); 658 remove (procs, *this); 659 push_front(idles, *this); 660 unlock (proc_list_lock); 661 } 662 663 __cfaabi_dbg_print_safe("Kernel : Processor %p ready to sleep\n", this); 664 665 sem_wait(&idleLock); 666 667 __cfaabi_dbg_print_safe("Kernel : Processor %p woke up and ready to run\n", this); 668 669 with( *cltr ) { 670 lock (proc_list_lock __cfaabi_dbg_ctx2); 671 remove (idles, *this); 672 push_front(procs, *this); 673 unlock (proc_list_lock); 674 } 675 } 676 677 void wake(processor * this) { 678 __cfaabi_dbg_print_safe("Kernel : Waking up processor %p\n", this); 679 sem_post(&this->idleLock); 680 } 646 681 647 682 //============================================================================================= -
src/libcfa/concurrency/kernel_private.h
r35718a9 r94b1022a 48 48 void BlockInternal(__spinlock_t * locks [], unsigned short count); 49 49 void BlockInternal(__spinlock_t * locks [], unsigned short count, thread_desc * thrds [], unsigned short thrd_count); 50 void BlockInternal(__finish_callback_fptr_t callback); 50 51 void LeaveThread(__spinlock_t * lock, thread_desc * thrd); 51 52 … … 56 57 void runThread(processor * this, thread_desc * dst); 57 58 void finishRunning(processor * this); 59 void halt(processor * this); 60 void wake(processor * this); 58 61 void terminate(processor * this); 59 62 void spin(processor * this, unsigned int * spin_count); -
src/libcfa/concurrency/monitor.c
r35718a9 r94b1022a 297 297 this.count = count; 298 298 299 // Sort monitors based on address -> TODO use a sort specialized for small numbers299 // Sort monitors based on address 300 300 __libcfa_small_sort(this.m, count); 301 301 -
src/libcfa/concurrency/preemption.c
r35718a9 r94b1022a 266 266 void terminate(processor * this) { 267 267 this->do_terminate = true; 268 wake(this); 268 269 sigval_t value = { PREEMPT_TERMINATE }; 269 270 pthread_sigqueue( this->kernel_thread, SIGUSR1, value );
Note:
See TracChangeset
for help on using the changeset viewer.