Changeset 84018e0


Ignore:
Timestamp:
May 8, 2023, 4:56:43 PM (13 months ago)
Author:
caparsons <caparson@…>
Branches:
ADT, ast-experimental, master
Children:
c4f411e
Parents:
2d831a1
Message:

cleaned up benchmark pseudocode

File:
1 edited

Legend:

Unmodified
Added
Removed
  • doc/theses/colby_parsons_MMAth/text/mutex_stmt.tex

    r2d831a1 r84018e0  
    350350
    351351The benchmark used to evaluate the avoidance algorithms repeatedly acquires a fixed number of locks in a random order and then releases them.
    352 The pseudo code for the deadlock avoidance benchmark is shown in \VRef[Listing]{l:deadlock_avoid_pseudo}.
     352The pseudocode for the deadlock avoidance benchmark is shown in \VRef[Listing]{l:deadlock_avoid_pseudo}.
    353353To ensure the comparison exercises the implementation of each lock avoidance algorithm, an identical spinlock is implemented in each language using a set of builtin atomics available in both \CC and \CFA.
    354354The benchmarks are run for a fixed duration of 10 seconds and then terminate.
     
    357357The median is calculated and is plotted alongside the 95\% confidence intervals for each point.
    358358
    359 \begin{cfa}[caption={Deadlock avoidance bendchmark pseudo code},label={l:deadlock_avoid_pseudo}]
    360 
    361 size_t N_LOCKS; $\C{// number of locks}$
    362 size_t N_THREADS; $\C{// number of threads}$
    363 size_t N_GENS; $\C{// number of random orderings (default 100)}$
     359\begin{cfa}[caption={Deadlock avoidance benchmark pseudocode},label={l:deadlock_avoid_pseudo}]
     360
     361size_t n_locks; $\C{// number of locks}$
     362size_t n_thds; $\C{// number of threads}$
     363size_t n_gens; $\C{// number of random orderings (default 100)}$
    364364size_t total = 0; $\C{// global throughput aggregator}$
    365365volatile bool done = false; $\C{// termination flag}$
    366366
    367 test_spinlock locks[N_LOCKS];
    368 size_t rands[N_THREADS][N_LOCKS * N_GENS]; $\C{// random ordering per thread}$
     367test_spinlock locks[n_locks];
     368size_t rands[n_thds][n_locks * n_gens]; $\C{// random ordering per thread}$
    369369
    370370void main( worker & w ) with(w) { $\C{// thread main}$
    371371    size_t count = 0, idx = 0;
    372372    while ( !done ) {
    373         idx = (count % N_LOCKS * N_GENS) * N_LOCKS; $\C{// get start of next sequence}$
    374         mutex(locks[rands[0]], ..., locks[rands[N_LOCKS - 1]]){} $\C{// lock sequence of locks}$
     373        idx = (count % n_locks * n_gens) * n_locks; $\C{// get start of next sequence}$
     374        mutex(locks[rands[0]], ..., locks[rands[n_locks - 1]]){} $\C{// lock sequence of locks}$
    375375        count++;
    376376    }
     
    381381    gen_orders(); $\C{// generate random orderings}$
    382382    {
    383         worker w[N_THREADS];
     383        worker w[n_thds];
    384384        sleep( 10`s );
    385385        done = true;
Note: See TracChangeset for help on using the changeset viewer.