Ignore:
Timestamp:
Nov 14, 2022, 11:52:44 AM (3 years ago)
Author:
caparson <caparson@…>
Branches:
ADT, ast-experimental, master
Children:
7d9598d8
Parents:
b77f0e1 (diff), 19a8c40 (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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • libcfa/src/concurrency/thread.cfa

    rb77f0e1 r63be3387  
    4444        self_mon_p = &self_mon;
    4545        curr_cluster = &cl;
    46         link.next = 0p;
    47         link.ts   = MAX;
     46        rdy_link.next = 0p;
     47        rdy_link.ts   = MAX;
    4848        preferred = ready_queue_new_preferred();
    4949        last_proc = 0p;
    5050        random_state = __global_random_mask ? __global_random_prime : __global_random_prime ^ rdtscl();
    5151        #if defined( __CFA_WITH_VERIFY__ )
     52                executing = 0p;
    5253                canary = 0x0D15EA5E0D15EA5Ep;
    5354        #endif
    54 
    55         node.next = 0p;
    56         node.prev = 0p;
    5755
    5856        clh_node = malloc( );
     
    177175
    178176//-----------------------------------------------------------------------------
     177bool migrate( thread$ * thrd, struct cluster & cl ) {
     178
     179        monitor$ * tmon = get_monitor(thrd);
     180        monitor$ * __monitors[] = { tmon };
     181        monitor_guard_t __guard = { __monitors, 1 };
     182
     183
     184        {
     185                // if nothing needs to be done, return false
     186                if( thrd->curr_cluster == &cl ) return false;
     187
     188                // are we migrating ourself?
     189                const bool local = thrd == active_thread();
     190
     191                /* paranoid */ verify( !local || &cl != active_cluster() );
     192                /* paranoid */ verify( !local || thrd->curr_cluster == active_cluster() );
     193                /* paranoid */ verify( !local || thrd->curr_cluster == active_processor()->cltr );
     194                /* paranoid */ verify( local || tmon->signal_stack.top->owner->waiting_thread == thrd );
     195                /* paranoid */ verify( local || tmon->signal_stack.top );
     196
     197                // make sure we aren't interrupted while doing this
     198                // not as important if we aren't local
     199                disable_interrupts();
     200
     201                // actually move the thread
     202                unregister( thrd->curr_cluster, *thrd );
     203                thrd->curr_cluster = &cl;
     204                doregister( thrd->curr_cluster, *thrd );
     205
     206                // restore interrupts
     207                enable_interrupts();
     208
     209                // if this is the local thread, we are still running on the old cluster
     210                if(local) yield();
     211
     212                /* paranoid */ verify( !local || &cl == active_cluster() );
     213                /* paranoid */ verify( !local || thrd->curr_cluster == active_cluster() );
     214                /* paranoid */ verify( !local || thrd->curr_cluster == active_processor()->cltr );
     215                /* paranoid */ verify(  local || tmon->signal_stack.top );
     216                /* paranoid */ verify(  local || tmon->signal_stack.top->owner->waiting_thread == thrd );
     217
     218                return true;
     219        }
     220}
     221
     222//-----------------------------------------------------------------------------
    179223#define GENERATOR LCG
    180224
Note: See TracChangeset for help on using the changeset viewer.