Changeset 84018e0 for doc/theses/colby_parsons_MMAth/text/mutex_stmt.tex
- Timestamp:
- May 8, 2023, 4:56:43 PM (16 months ago)
- Branches:
- ADT, ast-experimental, master
- Children:
- c4f411e
- Parents:
- 2d831a1
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
doc/theses/colby_parsons_MMAth/text/mutex_stmt.tex
r2d831a1 r84018e0 350 350 351 351 The 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 352 The pseudocode for the deadlock avoidance benchmark is shown in \VRef[Listing]{l:deadlock_avoid_pseudo}. 353 353 To 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. 354 354 The benchmarks are run for a fixed duration of 10 seconds and then terminate. … … 357 357 The median is calculated and is plotted alongside the 95\% confidence intervals for each point. 358 358 359 \begin{cfa}[caption={Deadlock avoidance ben dchmark pseudocode},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 361 size_t n_locks; $\C{// number of locks}$ 362 size_t n_thds; $\C{// number of threads}$ 363 size_t n_gens; $\C{// number of random orderings (default 100)}$ 364 364 size_t total = 0; $\C{// global throughput aggregator}$ 365 365 volatile bool done = false; $\C{// termination flag}$ 366 366 367 test_spinlock locks[ N_LOCKS];368 size_t rands[ N_THREADS][N_LOCKS * N_GENS]; $\C{// random ordering per thread}$367 test_spinlock locks[n_locks]; 368 size_t rands[n_thds][n_locks * n_gens]; $\C{// random ordering per thread}$ 369 369 370 370 void main( worker & w ) with(w) { $\C{// thread main}$ 371 371 size_t count = 0, idx = 0; 372 372 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}$ 375 375 count++; 376 376 } … … 381 381 gen_orders(); $\C{// generate random orderings}$ 382 382 { 383 worker w[ N_THREADS];383 worker w[n_thds]; 384 384 sleep( 10`s ); 385 385 done = true;
Note: See TracChangeset
for help on using the changeset viewer.