+++ /dev/null
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <pthread.h>
-
-#include "nbody.h"
-#include "graphics.h"
-
-unsigned numberOfProcessors;
-
-System universe;
-pthread_t compute_thread;
-pthread_mutex_t mutex_runstate;
-RUNSTATE runstate = RUN;
-
-void Thread_Cleanup(void)
-{
- if (runstate == RUN)
- QuitProgram(false);
- pthread_join(compute_thread, NULL);
-}
-
-// This is main function. Do not change it.
-int main(int argc, char** argv)
-{
- if (argc < 2)
- {
- printf("Please provide the filename, i.e. \'%s bodiesfield.dat\'\n", argv[0]);
- exit(EXIT_FAILURE);
- }
- if (argc == 2)
- {
- System_Init(&universe,argv[1]);
- atexit(Universe_Cleanup);
- }
- if (argc == 3)
- {
- numberOfProcessors = atoi(argv[2]);
- }
-
- atexit(Thread_Cleanup);
-
- // Create a thread to handle computation loop
-
- if (pthread_create(&compute_thread, NULL, Compute_Thread, (void*)&universe) != 0)
- {
- perror("Error creating compute thread");
- exit(EXIT_FAILURE);
- }
-
- Graphics_Run(argc, argv); // Run graphics loop in the main thread
-
- printf("Close!\n");
- //We get to this point when the "close" button is clicked in the graphics window
- QuitProgram(false);
- pthread_join(compute_thread, NULL);
-
-}
-