Write a C code to perform vector arithmetic: - Define 3 vectors A[100], B[100], C[100]. Get...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Write a C code to perform vector arithmetic: - Define 3 vectors A[100], B[100], C[100]. Get n from as a command line argument. Example if n=10, then (/vector 10), and create n processes. (n will be one of Divisors of 100). Get operation from user: add, sub. Each process will create a number of threads. Number of threads per process = 100/(10 number of processes). Perform the operation on a chunk of the vector, for example, if n = 10, each process will create (100/10*10=1) 1 thread to add sub 10 elements. Use execl to run the add or sub programs Parent should print A,B,C in a file. (yourname.txt) For example, n=5, operation-sub Partition work equally to each process: PO create (100/10*5=2) 2 threads → Thread00 will executes A[0:9] B[0:9]-C [0:9] Thread01 will executes A[10:19] B[10:19]- C[10:19] PI create (100/10*5=2) 2 threads → Thread 10 will executes A[20:29] = B[20:29] - C[20:29] Thread 11 will executes A[30:39] B[30:39]-C [30:39] and so on. no synchronization is required For example, if the output file named (vector) the output will be like this -/vector 5 B[100]-(1,2,3,4,3,2,3,3,etc..) C[100]-(4,2,9,4,1,2,3,3,...etc..) Enter the Operation for Add enter 1 for Sub enter 2:2 5 processes created, each process creates 2 threads. Parent process print A,B,C in. (Ahmad.txt) Write a C code to perform vector arithmetic: - Define 3 vectors A[100], B[100], C[100]. Get n from as a command line argument. Example if n=10, then (/vector 10), and create n processes. (n will be one of Divisors of 100). Get operation from user: add, sub. Each process will create a number of threads. Number of threads per process = 100/(10 number of processes). Perform the operation on a chunk of the vector, for example, if n = 10, each process will create (100/10*10=1) 1 thread to add sub 10 elements. Use execl to run the add or sub programs Parent should print A,B,C in a file. (yourname.txt) For example, n=5, operation-sub Partition work equally to each process: PO create (100/10*5=2) 2 threads → Thread00 will executes A[0:9] B[0:9]-C [0:9] Thread01 will executes A[10:19] B[10:19]- C[10:19] PI create (100/10*5=2) 2 threads → Thread 10 will executes A[20:29] = B[20:29] - C[20:29] Thread 11 will executes A[30:39] B[30:39]-C [30:39] and so on. no synchronization is required For example, if the output file named (vector) the output will be like this -/vector 5 B[100]-(1,2,3,4,3,2,3,3,etc..) C[100]-(4,2,9,4,1,2,3,3,...etc..) Enter the Operation for Add enter 1 for Sub enter 2:2 5 processes created, each process creates 2 threads. Parent process print A,B,C in. (Ahmad.txt)
Expert Answer:
Answer rating: 100% (QA)
Heres a sample C code that follows the specified requirements include include include include define ... View the full answer
Related Book For
Introduction to Algorithms
ISBN: 978-0262033848
3rd edition
Authors: Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest
Posted Date:
Students also viewed these operating system questions
-
Read "YOU'RE THE ECONOMIST: Why the High Cost of Health Care?" in Chapter 17. After reading the case, discuss the following questions: (1) Which of the causes of healthcare inflation discussed here...
-
At year-end 2010, 28,879 million represents: A. the funded status of the plan. B. the defined benefit obligation. C. the fair value of the plans assets. Kensington plc, a hypothetical company based...
-
Dozier Corporation is a fast-growing supplier of office products. Analysts project the following free cash flows (FCFs) during the next 3 years, after which FCF is expected to grow at a constant 7...
-
In exercise 27.3, we considered some ways in which we can differentiate between goods that lie in between the extremes of pure private and pure public goods. A: Consider the case where there is a...
-
Refer to the information in Exercise 24-3 and assume instead that double-declining depreciation is applied. Compute the machines payback period (ignore taxes). (Round the payback period to three...
-
Tom Belford and Tony Sorrentino own a small business devoted to kitchen and bath granite installations. Recently, building contractors have insisted on up-front bid prices for a house rather than the...
-
Discuss the market concentration, competitiveness, and performance of the Australian grocery industry compared to other western countries. Identify the key stakeholders in the food supply chain, and...
-
The number of auto accidents in Athens, Ohio, is related to the regional number of registered automobiles in thousands (X), alcoholic beverage sales in $10,000s (X), and rainfall in inches (X3)....
-
Please calculate the total deposits being created by BANKS A, B and C from the following Process: John came to Bank A and made a Cash deposit of $2,000 in Bank A. Then Carole went to Bank B and...
-
A very large nonconducting plate lying in the xy-plane carries a charge per unit area of 90. A second such plate located at z = 3.35 cm and oriented parallel to the xy-plane carries a charge per unit...
-
A premium annual - pay bond pays a $ 8 2 coupon, has a yield to maturity of 5 . 1 7 % , and is priced at $ 1 , 0 9 3 . 9 8 . How many years till the bond matures? Answer in years to at least two...
-
Who owns the rights to the AI images or art generated by these algorithms?
-
Evaluate Tire City's financial health. How well is the company performing?
-
A proposed change in income tax suggests charging 25 % on a person's income up to $ 42 , 000 and then 40 % on any income above that. If a person has an income of $ 68 , 000 , what will their income...
-
Beautiful Ltd ("Beautiful") is a cosmetic house which develops, manufactures and sells cosmetics and skincare products. All products are divided and sold under the various product lines. Currently,...
-
White Bolder Investments (WBI) You are an intern working for WBI, a large investment advisory services in Sydney. Among other regular customers, WBI has been providing advisory services for Jumbo...
-
What does the matrix used in the shortest-paths algorithms correspond to in regular matrix multiplication? 888 8 8 88
-
Professor Gaedel has written a program that he claims implements Dijkstras algorithm. The program produces .d and . for each vertex V. Give an O(V + E)-time algorithm to check the output of the...
-
Construct a computation dag for which one execution of a greedy scheduler can take nearly twice the time of another execution of a greedy scheduler on the same number of processors. Describe how the...
-
Calculate the ignition delay period (in deg ca) in a diesel engine using Eqns (16.15a) and (16.15b) using the conditions at the beginning of fuel injection that exist after compression in the engine...
-
This question is based on Fig. 16.9. An engine operating on an Otto cycle has a maximum peak pressure of \(60 \mathrm{bar}\). If the pressure and temperature at the beginning of the cycle are 1.0 bar...
-
Compare the air-standard cycle thermal efficiencies of an Otto cycle obtained by calculating the state points around the cycle with the value obtained from Eqn (3.16) for an 'engine' operating with a...
Study smarter with the SolutionInn App