Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

please make sure to follow all instructions listed , this is to be done in Ubuntu / Virual box using c programming . please make

please make sure to follow all instructions listed , this is to be done in Ubuntu / Virual box using c programming .
please make sure to include comments throughout code for a better understanding
thank you in advance !
image text in transcribed
you may use code similar to this , or refer to this as an example for help
please and thank you image text in transcribed
image text in transcribed
image text in transcribed
Part A Create a single threaded application that forms the sum save this as prog_parta.c. Note: N can be a very large number so make the variable of long long type. The result is to be stored in a global long long variable. Use as a format specifier Mild Part 3 Modify prog_parta.c to be a threaded version where the main() spawns a single thread. Save as prog_partb.c Note the result of this computation Part Modity prog_partb.c have a variable offset. That is instead of $$\sum _{i1}N 15$ form offseri param. Here N can be a a global variable as well. Test with offset_param=1. Compare to Part B. #define N 4002394023945803948 Part D Modify pro partec to have two threads using the same summing function. The first thread should use an offset parameter as 1 and the second should use an offset parameter 1. What is the theoretical result? What is the actual result? HINT: You could do something like the following int offset11 Int offset2n-offsett: Deliverables A zipped file containing all of the programs and a text file with the requisite commentary. #include #include #include int sum, sum2; struct more_info { char *first_parameter; char * second parameter; void *runnerl (void *param); void * runner2(void *param); void *print Param(void *param); int main(int argc, char *argv[]) { pthread_t tidi, tid2, tid3; pthread_attr_t attr; struct more info myinfo; if(argc != 3) { printf ("Usage : threadit "); return -1; } if(atoi (argv[1]) first_parameter); sum1 0; for (i=0; isecond_parameter); sum2 = 0; for (i=0; ifirst_parameter); sumi 0; for (i=0; isecond_parameter); sum2 = 0; for (i=0; ifirst parameter); printf("Second parameter %s ", arg->second parameter): Part A Create a single threaded application that forms the sum save this as prog_parta.c. Note: N can be a very large number so make the variable of long long type. The result is to be stored in a global long long variable. Use as a format specifier Mild Part 3 Modify prog_parta.c to be a threaded version where the main() spawns a single thread. Save as prog_partb.c Note the result of this computation Part Modity prog_partb.c have a variable offset. That is instead of $$\sum _{i1}N 15$ form offseri param. Here N can be a a global variable as well. Test with offset_param=1. Compare to Part B. #define N 4002394023945803948 Part D Modify pro partec to have two threads using the same summing function. The first thread should use an offset parameter as 1 and the second should use an offset parameter 1. What is the theoretical result? What is the actual result? HINT: You could do something like the following int offset11 Int offset2n-offsett: Deliverables A zipped file containing all of the programs and a text file with the requisite commentary. #include #include #include int sum, sum2; struct more_info { char *first_parameter; char * second parameter; void *runnerl (void *param); void * runner2(void *param); void *print Param(void *param); int main(int argc, char *argv[]) { pthread_t tidi, tid2, tid3; pthread_attr_t attr; struct more info myinfo; if(argc != 3) { printf ("Usage : threadit "); return -1; } if(atoi (argv[1]) first_parameter); sum1 0; for (i=0; isecond_parameter); sum2 = 0; for (i=0; ifirst_parameter); sumi 0; for (i=0; isecond_parameter); sum2 = 0; for (i=0; ifirst parameter); printf("Second parameter %s ", arg->second parameter)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Systems Introduction To Databases And Data Warehouses

Authors: Nenad Jukic, Susan Vrbsky, Svetlozar Nestorov

1st Edition

1943153191, 978-1943153190

More Books

Students also viewed these Databases questions

Question

In an Excel Pivot Table, how is a Fact/Measure Column repeated?

Answered: 1 week ago