X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=course%2Fsemester2%2Fpprog%2Fassignment1%2Fmthread%2Fmain.c;h=37e5985321bbd9f9ade691e08d60d5122cd91e5f;hb=c2c6a38870351a5702913ce8a97c25c51662a59c;hp=531624616e1c2a271d827fc3e47fe60fedc8e742;hpb=0f1c535d8b786d3cf5b28231135fe1172571425f;p=matches%2Fhonours.git diff --git a/course/semester2/pprog/assignment1/mthread/main.c b/course/semester2/pprog/assignment1/mthread/main.c deleted file mode 100644 index 53162461..00000000 --- a/course/semester2/pprog/assignment1/mthread/main.c +++ /dev/null @@ -1,59 +0,0 @@ - -#include -#include -#include - -#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); - -} - diff --git a/course/semester2/pprog/assignment1/mthread/main.c b/course/semester2/pprog/assignment1/mthread/main.c new file mode 120000 index 00000000..37e59853 --- /dev/null +++ b/course/semester2/pprog/assignment1/mthread/main.c @@ -0,0 +1 @@ +../single-thread/main.c \ No newline at end of file