Changeset 92b9958
- Timestamp:
- Apr 15, 2021, 4:54:01 PM (4 years ago)
- Branches:
- ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast-unique-expr, pthread-emulation, qualifiedEnum
- Children:
- a0e7d3c
- Parents:
- 200a229 (diff), e2cc3c7 (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. - Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
tests/concurrent/futures/multi.cfa
r200a229 r92b9958 5 5 6 6 thread Server { 7 int cnt, iteration;7 int pending, done, iteration; 8 8 multi_future(int) * request; 9 9 }; 10 10 11 11 void ?{}( Server & this ) { 12 this.cnt = 0; 12 ((thread&)this){"Server Thread"}; 13 this.pending = 0; 14 this.done = 0; 13 15 this.iteration = 0; 14 16 this.request = 0p; … … 16 18 17 19 void ^?{}( Server & mutex this ) { 18 assert(this. cnt== 0);19 20 assert(this.pending == 0); 21 this.request = 0p; 20 22 } 21 23 … … 24 26 } 25 27 26 void process( Server & mutex this ) { 27 fulfil( *this.request, this.iteration ); 28 this.iteration++; 28 void call( Server & mutex this ) { 29 this.pending++; 29 30 } 30 31 31 void call( Server & mutex this ) {32 this. cnt++;32 void finish( Server & mutex this ) { 33 this.done++; 33 34 } 34 35 35 void finish( Server & mutex this ) { }36 37 36 void main( Server & this ) { 37 MAIN_LOOP: 38 38 for() { 39 39 waitfor( ^?{} : this ) { 40 40 break; 41 41 } 42 or when( this.cnt < NFUTURES ) waitfor( call: this ) { 43 if (this.cnt == NFUTURES) { 44 process(this); 42 or waitfor( call: this ) { 43 if (this.pending != NFUTURES) { continue MAIN_LOOP; } 44 45 this.pending = 0; 46 fulfil( *this.request, this.iteration ); 47 this.iteration++; 48 49 for(NFUTURES) { 50 waitfor( finish: this ); 45 51 } 46 } 47 or waitfor( finish: this ) { 48 if (this.cnt == NFUTURES) { 49 reset( *this.request ); 50 this.cnt = 0; 51 } 52 53 reset( *this.request ); 54 this.done = 0; 52 55 } 53 56 } … … 57 60 Server * the_server; 58 61 thread Worker {}; 62 void ?{}(Worker & this) { 63 ((thread&)this){"Worker Thread"}; 64 } 65 59 66 multi_future(int) * shared_future; 60 67 -
tests/concurrent/spinaphore.cfa
r200a229 r92b9958 49 49 void main(Unblocker & this) { 50 50 this.sum = 0; 51 unsigned me = (unsigned) &this;51 unsigned me = (unsigned)(uintptr_t)&this; 52 52 for(num_unblocks) { 53 53 $thread * t = V(sem, false); 54 54 Blocker * b = from_thread(t); 55 55 b->sum += me; 56 this.sum += (unsigned) b;56 this.sum += (unsigned)(uintptr_t)b; 57 57 unpark(t); 58 58 yield(random(10)); … … 73 73 for(i;num_blockers) { 74 74 for(num_blocks) 75 usum += (unsigned) &blockers[i];75 usum += (unsigned)(uintptr_t)&blockers[i]; 76 76 } 77 77 78 78 for(i;num_unblockers) { 79 79 for(num_unblocks) 80 bsum += (unsigned) &unblockers[i];80 bsum += (unsigned)(uintptr_t)&unblockers[i]; 81 81 } 82 82 -
tools/gdb/utils-gdb.py
r200a229 r92b9958 480 480 context = thread['context'] 481 481 482 483 484 # must be at frame 0 to set pc register 485 gdb.execute('select-frame 0') 486 if gdb.selected_frame().architecture().name() != 'i386:x86-64': 487 print('gdb debugging only supported for i386:x86-64 for now') 488 return 489 490 # gdb seems to handle things much better if we pretend we just entered the context switch 491 # pretend the pc is __cfactx_switch and adjust the sp, base pointer doesn't need to change 482 492 # lookup for sp,fp and uSwitch 483 xsp = context['SP'] + 4 8493 xsp = context['SP'] + 40 # 40 = 5 64bit registers : %r15, %r14, %r13, %r12, %rbx WARNING: x64 specific 484 494 xfp = context['FP'] 485 495 486 496 # convert string so we can strip out the address 487 497 try: 488 xpc = get_addr(gdb.parse_and_eval('__cfactx_switch').address + 28)498 xpc = get_addr(gdb.parse_and_eval('__cfactx_switch').address) 489 499 except: 490 500 print("here") 491 501 return 492 493 # must be at frame 0 to set pc register494 gdb.execute('select-frame 0')495 502 496 503 # push sp, fp, pc into a global stack … … 503 510 504 511 # update registers for new task 505 print('switching to ') 512 # print('switching to {} ({}) : [{}, {}, {}]'.format(thread['self_cor']['name'].string(), str(thread), str(xsp), str(xfp), str(xpc))) 513 print('switching to thread {} ({})'.format(str(thread), thread['self_cor']['name'].string())) 506 514 gdb.execute('set $rsp={}'.format(xsp)) 507 515 gdb.execute('set $rbp={}'.format(xfp)) … … 552 560 553 561 argv = parse(arg) 554 print(argv)555 562 if argv[0].isdigit(): 556 563 cname = " ".join(argv[1:]) if len(argv) > 1 else None
Note: See TracChangeset
for help on using the changeset viewer.