Changeset 9042795 for src/libcfa
- Timestamp:
- May 2, 2017, 7:18:52 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, resolv-new, with_gc
- Children:
- 6db9dab
- Parents:
- ed8a0d2 (diff), b510ac2 (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. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified src/libcfa/concurrency/monitor.c ¶
red8a0d2 r9042795 17 17 #include "monitor" 18 18 19 #include <stdlib> 20 19 21 #include "kernel_private.h" 20 22 #include "libhdr.h" … … 130 132 this_thread()->current_monitors = this->prev_mntrs; 131 133 this_thread()->current_monitor_count = this->prev_count; 134 } 135 136 void debug_break() __attribute__(( noinline )) 137 { 138 132 139 } 133 140 … … 171 178 172 179 //Find the next thread(s) to run 173 unsigned short thread_count = count;180 unsigned short thread_count = 0; 174 181 thread_desc * threads[ count ]; 182 for(int i = 0; i < count; i++) { 183 threads[i] = 0; 184 } 185 186 debug_break(); 175 187 176 188 for( int i = 0; i < count; i++) { 177 189 thread_desc * new_owner = next_thread( this->monitors[i] ); 178 thread_count = insert_unique( threads, i, new_owner ); 179 } 190 thread_count = insert_unique( threads, thread_count, new_owner ); 191 } 192 193 debug_break(); 180 194 181 195 LIB_DEBUG_PRINT_SAFE("Will unblock: "); … … 339 353 LIB_DEBUG_PRINT_SAFE("Branding\n"); 340 354 assertf( thrd->current_monitors != NULL, "No current monitor to brand condition", thrd->current_monitors ); 341 this->monitors = thrd->current_monitors;342 355 this->monitor_count = thrd->current_monitor_count; 356 357 this->monitors = malloc( this->monitor_count * sizeof( *this->monitors ) ); 358 for( int i = 0; i < this->monitor_count; i++ ) { 359 this->monitors[i] = thrd->current_monitors[i]; 360 } 343 361 } 344 362 } 345 363 346 364 static inline unsigned short insert_unique( thread_desc ** thrds, unsigned short end, thread_desc * val ) { 347 for(int i = 0; i < end; i++) { 365 if( !val ) return end; 366 367 for(int i = 0; i <= end; i++) { 348 368 if( thrds[i] == val ) return end; 349 369 }
Note: See TracChangeset
for help on using the changeset viewer.