ADT
        aaron-thesis
        arm-eh
        ast-experimental
        cleanup-dtors
        deferred_resn
        demangler
        enum
        forall-pointer-decay
        jacob/cs343-translation
        jenkins-sandbox
        new-ast
        new-ast-unique-expr
        new-env
        no_list
        persistent-indexer
        pthread-emulation
        qualifiedEnum
        resolv-new
        with_gc
      
      
        
          | 
            Last change
 on this file since d2e2865 was             eb2fe4f, checked in by Thierry Delisle <tdelisle@…>, 8 years ago           | 
        
        
          | 
             
Some cleanu[ of the benchmark for pthread create 
 
           | 
        
        
          
            
              - 
Property                 mode
 set to                 
100644
               
             
           | 
        
        
          | 
            File size:
            550 bytes
           | 
        
      
      
| Line |   | 
|---|
| 1 | #include <pthread.h>
 | 
|---|
| 2 | #include <err.h>
 | 
|---|
| 3 | #include <stdlib.h>
 | 
|---|
| 4 | #include <stdio.h>
 | 
|---|
| 5 | 
 | 
|---|
| 6 | static void *foo(void *arg) {
 | 
|---|
| 7 |     return arg;
 | 
|---|
| 8 | }
 | 
|---|
| 9 | 
 | 
|---|
| 10 | int main(int argc, char* argv[]) {
 | 
|---|
| 11 |         size_t n = 1000000;
 | 
|---|
| 12 |         if( argc > 2 ) return 1;
 | 
|---|
| 13 |         if( argc == 2 ) {
 | 
|---|
| 14 |                 n = atoi(argv[1]);
 | 
|---|
| 15 |         }
 | 
|---|
| 16 |         printf("create %lu pthreads ... ", n);
 | 
|---|
| 17 | 
 | 
|---|
| 18 |         for (size_t i = 0; i < n; i++) {
 | 
|---|
| 19 |                 pthread_t thread;
 | 
|---|
| 20 |                 if (pthread_create(&thread, NULL, foo, NULL) < 0) {
 | 
|---|
| 21 |                         perror( "failure" );
 | 
|---|
| 22 |                         return 1;
 | 
|---|
| 23 |                 }
 | 
|---|
| 24 | 
 | 
|---|
| 25 |                 if (pthread_join( thread, NULL) < 0) {
 | 
|---|
| 26 |                         perror( "failure" );
 | 
|---|
| 27 |                         return 1;
 | 
|---|
| 28 |                 }
 | 
|---|
| 29 |         }
 | 
|---|
| 30 |         printf("finish\n");
 | 
|---|
| 31 | }
 | 
|---|
       
      
  Note:
 See   
TracBrowser
 for help on using the repository browser.