Type your programming question here…
how to create multiple threads program in c. The program requires two command line arguments to be executed and they are
1-numthreads-n integer value that specifies how many threads will be created.
2-increment-the number of integer values that each thread will work with.
the program creates the specified number of threads and assigns to each one of them an interval of integer values say{a ,b} where (a) is the starting value and (b-1) is the end value. Each thread computes a value (S) which is
if your student-id mod3=0, then the summation of the integers in its interval, that is: a+(a+1)+(a+2)…..+(b-2)+(b-1). In other word you compute the sum of the integers.
if your student-id mod 3=1 then the summation of the squares of integers in its interval that is
a^2+(a+1)^2+(a+2)^2….+(b-2)^2+(b-1)^2.In other words you compute the sum of squares.
If your student-id mod3=2 then the product of integers in its interval, that is
a(a+1) (a+2)…….(b-2)(b-1).In other word you compute the factorial.
Finally, compute the time it takes to execute the programme. Also, extend the program further so that each thread will compute the time it takes to execute individually and print the result.


0 comments