| Last change
 on this file since 5546eee4 was             b2fa3c2, checked in by Peter A. Buhr <pabuhr@…>, 2 years ago | 
        
          | 
fix comments referring to concurrency directory
 | 
        
          | 
              
Property                 mode
 set to                 100644 | 
        
          | File size:
            1.1 KB | 
      
      
| Rev | Line |  | 
|---|
| [5f53cc3] | 1 | // | 
|---|
|  | 2 | // Cforall Version 1.0.0 Copyright (C) 2022 University of Waterloo | 
|---|
|  | 3 | // | 
|---|
|  | 4 | // The contents of this file are covered under the licence agreement in the | 
|---|
|  | 5 | // file "LICENCE" distributed with Cforall. | 
|---|
|  | 6 | // | 
|---|
| [b2fa3c2] | 7 | // barrier_sleeper.cfa -- testing the ready-queue | 
|---|
| [5f53cc3] | 8 | // | 
|---|
|  | 9 | // Author           : Thierry Delisle | 
|---|
|  | 10 | // Created On       : Fri Apr 01 14:01:00 2022 | 
|---|
|  | 11 | // Last Modified By : | 
|---|
|  | 12 | // Last Modified On : | 
|---|
|  | 13 | // Update Count     : | 
|---|
|  | 14 | // | 
|---|
|  | 15 |  | 
|---|
|  | 16 | // Test validates that processors running out of work repeatedly won't deadlock | 
|---|
|  | 17 | // Processors and thread are removed in an interleaved fashion for a weirder case. | 
|---|
|  | 18 |  | 
|---|
|  | 19 | #include <concurrency/barrier.hfa> | 
|---|
|  | 20 | #include <fstream.hfa> | 
|---|
|  | 21 | #include <time.hfa> | 
|---|
|  | 22 | #include <thread.hfa> | 
|---|
|  | 23 |  | 
|---|
|  | 24 | const unsigned NUM_LAPS = 173; | 
|---|
|  | 25 | const unsigned NUM_THREADS = 11; | 
|---|
|  | 26 |  | 
|---|
|  | 27 | barrier bar = { NUM_THREADS }; | 
|---|
|  | 28 |  | 
|---|
|  | 29 | thread Eager {}; | 
|---|
|  | 30 | void main( Eager & ) { | 
|---|
|  | 31 | for(NUM_LAPS) { | 
|---|
|  | 32 | block(bar); | 
|---|
|  | 33 | } | 
|---|
|  | 34 | } | 
|---|
|  | 35 |  | 
|---|
|  | 36 | thread Sleeper{}; | 
|---|
|  | 37 | void main( Sleeper & ) { | 
|---|
|  | 38 | for(NUM_LAPS) { | 
|---|
|  | 39 | sleep(500`us); | 
|---|
|  | 40 | block(bar); | 
|---|
|  | 41 | } | 
|---|
|  | 42 | } | 
|---|
|  | 43 |  | 
|---|
|  | 44 | int main() { | 
|---|
|  | 45 | { | 
|---|
|  | 46 | processor p1[2]; | 
|---|
|  | 47 | { | 
|---|
|  | 48 | if (NUM_THREADS <= 4) sout | "Insufficient threads"; | 
|---|
|  | 49 | Eager e[NUM_THREADS - 3]; | 
|---|
|  | 50 | { | 
|---|
|  | 51 | processor p2[2]; | 
|---|
|  | 52 | { | 
|---|
|  | 53 | Sleeper s[3]; | 
|---|
|  | 54 | } | 
|---|
|  | 55 | } | 
|---|
|  | 56 | } | 
|---|
|  | 57 | } | 
|---|
|  | 58 | sout | "Done"; | 
|---|
| [b2fa3c2] | 59 | } | 
|---|
       
      
  Note:
 See   
TracBrowser
 for help on using the repository browser.