Changeset 92b9958


Ignore:
Timestamp:
Apr 15, 2021, 4:54:01 PM (6 months ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
arm-eh, jacob/cs343-translation, master, new-ast-unique-expr
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.
Message:

Merge branch 'master' of plg.uwaterloo.ca:software/cfa/cfa-cc

Files:
3 edited

Legend:

Unmodified
Added
Removed
  • tests/concurrent/futures/multi.cfa

    r200a229 r92b9958  
    55
    66thread Server {
    7         int cnt, iteration;
     7        int pending, done, iteration;
    88        multi_future(int) * request;
    99};
    1010
    1111void ?{}( Server & this ) {
    12         this.cnt = 0;
     12        ((thread&)this){"Server Thread"};
     13        this.pending = 0;
     14        this.done = 0;
    1315        this.iteration = 0;
    1416        this.request = 0p;
     
    1618
    1719void ^?{}( Server & mutex this ) {
    18         assert(this.cnt == 0);
    19     this.request = 0p;
     20        assert(this.pending == 0);
     21        this.request = 0p;
    2022}
    2123
     
    2426}
    2527
    26 void process( Server & mutex this ) {
    27         fulfil( *this.request, this.iteration );
    28         this.iteration++;
     28void call( Server & mutex this ) {
     29        this.pending++;
    2930}
    3031
    31 void call( Server & mutex this ) {
    32         this.cnt++;
     32void finish( Server & mutex this ) {
     33        this.done++;
    3334}
    3435
    35 void finish( Server & mutex this ) { }
    36 
    3736void main( Server & this ) {
     37        MAIN_LOOP:
    3838        for() {
    3939                waitfor( ^?{} : this ) {
    4040                        break;
    4141                }
    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 );
    4551                        }
    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;
    5255                }
    5356        }
     
    5760Server * the_server;
    5861thread Worker {};
     62void ?{}(Worker & this) {
     63        ((thread&)this){"Worker Thread"};
     64}
     65
    5966multi_future(int) * shared_future;
    6067
  • tests/concurrent/spinaphore.cfa

    r200a229 r92b9958  
    4949void main(Unblocker & this) {
    5050        this.sum = 0;
    51         unsigned me = (unsigned)&this;
     51        unsigned me = (unsigned)(uintptr_t)&this;
    5252        for(num_unblocks) {
    5353                $thread * t = V(sem, false);
    5454                Blocker * b = from_thread(t);
    5555                b->sum += me;
    56                 this.sum += (unsigned)b;
     56                this.sum += (unsigned)(uintptr_t)b;
    5757                unpark(t);
    5858                yield(random(10));
     
    7373                for(i;num_blockers) {
    7474                        for(num_blocks)
    75                                 usum += (unsigned)&blockers[i];
     75                                usum += (unsigned)(uintptr_t)&blockers[i];
    7676                }
    7777
    7878                for(i;num_unblockers) {
    7979                        for(num_unblocks)
    80                                 bsum += (unsigned)&unblockers[i];
     80                                bsum += (unsigned)(uintptr_t)&unblockers[i];
    8181                }
    8282
  • tools/gdb/utils-gdb.py

    r200a229 r92b9958  
    480480                context = thread['context']
    481481
     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
    482492                # lookup for sp,fp and uSwitch
    483                 xsp = context['SP'] + 48
     493                xsp = context['SP'] + 40 # 40 = 5 64bit registers : %r15, %r14, %r13, %r12, %rbx WARNING: x64 specific
    484494                xfp = context['FP']
    485495
    486496                # convert string so we can strip out the address
    487497                try:
    488                         xpc = get_addr(gdb.parse_and_eval('__cfactx_switch').address + 28)
     498                        xpc = get_addr(gdb.parse_and_eval('__cfactx_switch').address)
    489499                except:
    490500                        print("here")
    491501                        return
    492 
    493                 # must be at frame 0 to set pc register
    494                 gdb.execute('select-frame 0')
    495502
    496503                # push sp, fp, pc into a global stack
     
    503510
    504511                # 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()))
    506514                gdb.execute('set $rsp={}'.format(xsp))
    507515                gdb.execute('set $rbp={}'.format(xfp))
     
    552560
    553561                argv = parse(arg)
    554                 print(argv)
    555562                if argv[0].isdigit():
    556563                        cname = " ".join(argv[1:]) if len(argv) > 1 else None
Note: See TracChangeset for help on using the changeset viewer.