Source

fcfs-rwlock / pthreads / test_rwlock.c

Diff from to

File pthreads/test_rwlock.c

 
 #include <pthread/rwlock_fcfs.h>
 
-static const pthread_mutex_t initial_mutex_constant = 
+static const pthread_mutex_t initial_mutex_constant =
     PTHREAD_MUTEX_INITIALIZER
     ;
 
             struct timespec timeout;
             struct timezone tz;
             int ret;
-            
+
             gettimeofday(&now, &tz);
             timeout.tv_nsec = (now.tv_usec + (rand()%1000000));
             if (timeout.tv_nsec > 1000000)
                 timeout.tv_sec += timeout.tv_nsec / 1000000;
                 timeout.tv_nsec %= 1000000;
             }
-            
+
             timeout.tv_nsec *= 1000;
             ret = pthread_rwlock_fcfs_timed_gain_read(
                 mylock,
             if (ret == 0)
             {
                 pthread_rwlock_fcfs_release(mylock PTHREAD_RWLOCK_FCFS_DEBUG_CALL_ARGS);
-            } 
+            }
 
             usleep(rand()%1000000);
             fflush(stdout);
             int ret;
             ret = pthread_rwlock_fcfs_try_gain_read(mylock PTHREAD_RWLOCK_FCFS_DEBUG_CALL_ARGS);
 
-            usleep(rand()%1000000);            
+            usleep(rand()%1000000);
 
             if (ret == 0)
             {
 
     pthread_mutex_lock(&num_active_mutex);
     num_active_threads--;
-    pthread_mutex_unlock(&num_active_mutex);  
+    pthread_mutex_unlock(&num_active_mutex);
 
     return NULL;
 }
             struct timespec timeout;
             struct timezone tz;
             int ret;
-            
+
             gettimeofday(&now, &tz);
             timeout.tv_nsec = (now.tv_usec + (rand()%1000000));
             if (timeout.tv_nsec > 1000000)
                 timeout.tv_sec += timeout.tv_nsec / 1000000;
                 timeout.tv_nsec %= 1000000;
             }
-            
+
             timeout.tv_nsec *= 1000;
             ret = pthread_rwlock_fcfs_timed_gain_write(
                 mylock,
             if (ret == 0)
             {
                 pthread_rwlock_fcfs_release(mylock PTHREAD_RWLOCK_FCFS_DEBUG_CALL_ARGS);
-            } 
+            }
 
             usleep(rand()%1000000);
             fflush(stdout);
             int ret;
             ret = pthread_rwlock_fcfs_try_gain_write(mylock PTHREAD_RWLOCK_FCFS_DEBUG_CALL_ARGS);
 
-            usleep(rand()%1000000);            
+            usleep(rand()%1000000);
 
             if (ret == 0)
             {
 
     pthread_mutex_lock(&num_active_mutex);
     num_active_threads--;
-    pthread_mutex_unlock(&num_active_mutex);  
+    pthread_mutex_unlock(&num_active_mutex);
 
     return NULL;
 }
             reader_thread,
             context
             );
-        
+
         if (check != 0)
         {
             fprintf(stderr, "Could not create Reader #%i!\n", a);
             writer_thread,
             context
             );
-        
+
         if (check != 0)
         {
             fprintf(stderr, "Could not create Writer #%i!\n", a);
         int local_num_active = 1;
         sleep(timeout);
         stop = 1;
-        
+
         while (local_num_active)
         {
             usleep(500);
     {
         pthread_join(writers[a], NULL);
     }
-    
+
 
     free(readers);
     free(writers);