diff --git a/lab4/src/threads/threading b/lab4/src/threads/threading deleted file mode 100755 index 5ae8700..0000000 Binary files a/lab4/src/threads/threading and /dev/null differ diff --git a/lab4/src/threads/threads.cpp b/lab4/src/threads/threads.cpp index 6e02857..fd29bfd 100644 --- a/lab4/src/threads/threads.cpp +++ b/lab4/src/threads/threads.cpp @@ -41,7 +41,7 @@ void* S1_smoothen(void* thread_number) // struct image_t* smoother = new struct image_t; for(pt = 1; pt <= 1000; ++pt) { while(__sync_lock_test_and_set(&lock1,1)); - printf("thread number : %d\tindex : %d\n", my_number, pt); + // printf("thread number : %d\tindex : %d\n", my_number, pt); for(int i = 1; i < height-1; i++) { for(int j = 1; j < width-1; j++) @@ -106,7 +106,7 @@ void* S2_find_details(void *thread_number) while(__sync_lock_test_and_set(&lock3,1)); // while(lock_stream1.test_and_set()); // while(lock_stream2.test_and_set()); - printf("thread number : %d\tindex : %d\n", my_number, pt1); + // printf("thread number : %d\tindex : %d\n", my_number, pt1); for(int i = 1; i < height-1; i++) { for(int j = 1; j < width-1; j++) @@ -142,7 +142,7 @@ void* S3_sharpen(void* thread_number) while (__sync_lock_test_and_set(&lock4, 1)); while (__sync_lock_test_and_set(&lock3, 1)); - printf("thread number : %d\tindex : %d\n", my_number, pt2); + // printf("thread number : %d\tindex : %d\n", my_number, pt2); for(int i = 1; i < height-1; i++) { for(int j = 1; j < width-1; j++) @@ -215,6 +215,7 @@ int main(int argc, char *argv[]) { sharp->image_pixels[i][j] = new uint8_t[3]; } + auto start = chrono::high_resolution_clock::now(); /* Create independent threads each of which will execute function */ iret1 = pthread_create(&thread1, NULL, S1_smoothen, &thread_number1); @@ -240,8 +241,12 @@ int main(int argc, char *argv[]) { pthread_join(thread2, NULL); pthread_join(thread3, NULL); + auto end = std::chrono::high_resolution_clock::now(); + + chrono::duration duration = end - start; + cout << "Total time: " << duration.count() << endl; + // printf("\nsum = %d\n", sum); - printf("ttis"); exit(EXIT_SUCCESS); - return 1; + }