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 994d080 was             d6ff3ff, checked in by Thierry Delisle <tdelisle@…>, 8 years ago           | 
        
        
          | 
             
Kernel shoud now drop preemptions during other preemptions 
 
           | 
        
        
          
            
              - 
Property                 mode
 set to                 
100644
               
             
           | 
        
        
          | 
            File size:
            494 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("%lu\n", 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 |                         return 1;
 | 
|---|
| 22 |                 }
 | 
|---|
| 23 | 
 | 
|---|
| 24 |                 if (pthread_join( thread, NULL) < 0) {
 | 
|---|
| 25 |                         return 1;
 | 
|---|
| 26 |                 }
 | 
|---|
| 27 |         }
 | 
|---|
| 28 |         pthread_exit(NULL);
 | 
|---|
| 29 |         return 0;
 | 
|---|
| 30 | }
 | 
|---|
       
      
  Note:
 See   
TracBrowser
 for help on using the repository browser.