threads time added

This commit is contained in:
jazzy1902 2024-11-04 02:55:41 +05:30
parent be78df9fe5
commit 5ebcf72b1f
2 changed files with 10 additions and 5 deletions

Binary file not shown.

View File

@ -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<double> duration = end - start;
cout << "Total time: " << duration.count() << endl;
// printf("\nsum = %d\n", sum);
printf("ttis");
exit(EXIT_SUCCESS);
return 1;
}