From 5ebcf72b1f5392c97b5754c98cda5a6b1d9019ca Mon Sep 17 00:00:00 2001 From: jazzy1902 Date: Mon, 4 Nov 2024 02:55:41 +0530 Subject: [PATCH] threads time added --- lab4/src/threads/threading | Bin 41240 -> 0 bytes lab4/src/threads/threads.cpp | 15 ++++++++++----- 2 files changed, 10 insertions(+), 5 deletions(-) delete mode 100755 lab4/src/threads/threading diff --git a/lab4/src/threads/threading b/lab4/src/threads/threading deleted file mode 100755 index 5ae87006b5c71f1edffd9f61f42326d81173625c..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 41240 zcmeHw4}4VBo$pOZBp^D$qM}%t`mazmW+wlowh_2EDMBM57P0m+OeSO`nMo%%5UjY- zA)0xUSlTC*-L);-wJUGeR%$JqM^OV(6SvexW!to}YqV5n8m!S;rCoL2_jmr>x%Xx! znXvu5&+dCUI`^FOJHLPDcYf!0&pqdc`&a6XD{^yk6q#lypHZkbaw&&Yi-!4sEego0 zl}hC-T%F27u`9^9-##4d+_(0s)_aoap9LAx(Y}2P-m{8d6SlnbO!?-Xe3Q zkk^SWpNdYpAUWC9$g7s~y3EaVOkS(Nx8*+*%E;VIN4Dv^lhgI}So03i?=jgKp(mM( z=mrJdprDg^p|GdSr9Fua{VD}tdtQt-N;0?8H3>RVB&?oQ}L&LDwzp zXwQ#u_KM71zF8NX0Jkd`0kDs~Z&TS{F!>87K`lGA< z*Ps3zuig1J;gH@$LpYR(pBQqZei=%H!|aiBH}ojXCD;`VLs5qO&$nFOGG|%UJ25$Z zL`y1b27_}_RipG~2KY%Rmk$3qD3}g@9h6Q7|9%Gk`!nFbm_cqoG)~9=o(%fz&%mcS zgWQKRz?WsgFY1* z;D4O~PV>NtpFMpogPzZ1fd3H;()kI*rsaQC2Kc=h`1}EKFF~6O{_xsW%bG($|61?HW1jW`A&# z-lT3(wDqf}P9Eq`TR5ewlnV?sLZsi@l1`*r5opswt^S}CCy4?R5iN76wJWIuC0b3W zP5V6PTS5&m1u2{r2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d?MqSs*Ya`fSrbOrX s3-Ocs%lI`5FsVC=MyibQ;t#MdYfe(Ggv~`E9esiVBhpni0$Wx2KN#+QBLDyZ 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; + }