Parallel Programming - Finished pthreads
[matches/honours.git] / course / semester2 / pprog / assignment1 / mthread / nbody.h
index 7abe525..9948e52 100644 (file)
@@ -4,6 +4,7 @@
 
 #include "../single-thread/nbody.h" //Use original simulation code
 #include <pthread.h>
+#include "barrier.h" // Barriers
 
 #undef SINGLE_THREADED
 #define PTHREADED
@@ -28,25 +29,22 @@ void AfterDraw();
 
 void * Compute_Thread(void * system); //Thread - Continuously perform computations for a System of bodies. May spawn additional worker threads.
 
+
+
+
+System * Split_System(System * s, unsigned n); // Splits one system into a number of other systems, returns an array of size n
+pthread_t * Allocate_Threads(unsigned n); // Allocates space for threads - handles errors
+
 #ifdef PERSISTENT_THREADS
 void * Worker_Thread(void * arg);
-#else
+#endif //PERSISTENT_THREADS
 void * Force_Thread(void * system); //Thread - Compute forces for all objects in a system
 void * Position_Thread(void * system); //Thread - Compute positions for all objects in a system
-#endif //PERSISTENT_THREADS
 
 void Thread_Cleanup(void); //Called at program exit to safely join computation thread
 
-typedef struct
-{
-       pthread_mutex_t mutex;
-       unsigned threads_busy; // Counter of threads which are busy
-       pthread_cond_t threads_done_cv;
-} Barrier;
-
-void Barrier_Init(Barrier * b);
-void Barrier_Enter(Barrier * b);
-void Barrier_Leave(Barrier * b);
-void Barrier_Wait(Barrier * b);
+
+
+void * StepFunction(void * s); //Function called at the end of every step
 
 #endif //_NBODY_MTHREAD_H

UCC git Repository :: git.ucc.asn.au