Answered step by step
Verified Expert Solution
Question
1 Approved Answer
4) (10 points) In this question, we introduce the macro WEXITSTATUS (int status) defined in header. This macro evaluates to the least significant 8 bits
4) (10 points) In this question, we introduce the macro WEXITSTATUS (int status) defined in header. This macro evaluates to the least significant 8 bits of the exit status value that the child process passed to exit (). You can take the following code as an example. int main()\{ int status; pid_t pid = fork ();// Create a child process. if (pid == 0 ) exit (50);// The child process terminates and passes 50 as the exit status value. wait (\&status); // The parent process waits and receives the exit status value of the child process. int value = WEXITSTATUS(status); // value = 50 return 0 ; In this question, we want to use fork() to implement a dot product between two vectors with multiple processes. For example, given two vectors a=[3,2,4] and b=[1,5,2], the dot product between a and b is ab=31+25+42=21. The input of our program includes two vectors. The output is the dot product between them. The input data satisfies the following conditions. 1. The elements of the vectors are all non-negative integers. 2. The number of elements in each vector is fixed to 5 . 3. The result of the dot product is less than 256. Please fill in the five blanks to complete the following program. You can write at most 20 characters in each blank (10 points, 2 points for each blank). Sample Input: 34315 21452 Sample Output: The result of the dot product is 37 Write your answer in the following blanks. Blank 1: Blank 2: Blank 3: Blank 4
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started