subject
Engineering, 20.11.2019 17:31 audjwood67

Write the code to implement these functions. they should only consider the current expression, which is the first expression in the buffer, or, equivalently, everything up until the first semicolon. do not implement synchronization and mutual exclusion yet. tip: see sentinel() for an example invocation of strcpy() that shifts the characters in a string to the left. tip: if you are not certain which stdlib functions to use for string/number manipulation, feel free to use the provided utility functions (string2int, int2string, isnumeric). pseudocode for adder/multiplier: a. scan through current expression looking for a number. b. check each number to see if it is followed by a +/*, and then a numeric character (indicating the start of another number). c. if it is, add/multiply the two numbers, and replace the addition/multiplication subexpression with the result, e. g., "34+22" becomes "56". pseudocode for degrouper: a. scan through current expression looking for a '('. b. check if the next character is numeric (indicating the start of a number). c. if it is, check if the number is immediately followed by a ')'. d. if so, we have something like "(32432)". now remove the '(' and ')' we've just located from the expression. the above pseudocode is only a suggestion; your code may work differently. for example, you could hunt for + or * in the expression, then check that there are "naked" numbers to the left and right. q1: at this point, your solution does not contain any synchronization or mutual exclusion. give an example of and explain a possible synchronization error that could occur in this code. be specific. q2: suppose we implement correct synchronization and mutual exclusion for all of the threads. if our three functions were to operate on all expression in the buffer at once (not just the first expression), would the program generate incorrect output? why or why not? identify and protect the critical sections of the adder, multiplier and degrouper functions with a posix mutex. try to keep your critical sections as small as possible. tip: man pthread_mutex_lock, pthread_mutex_unlock, pthread_mutex_init, check the return values of these functions for errors. print a brief error message on stderr and exit your program with exit_failure if one of them fails. use the provided function next, identify and protect the critical sections of the reader and sentinel functions, as well. your code should now be immune to synchronization errors (e. g., race conditions, data corruption). q3: for this step, what specific data structure(s) need(s) protection? why? q4: what would happen if you had a busy-wait within one of your critical sections? what if it is a loop with q5: why is it sometimes necessary to use the non-blocking pthread_mutex_trylock() instead of the blocking think for example of a program that needs to acquire multiple mutexes at the same time. store the number of operations performed by your calculator in the variable num_ops, which is printed out before successful program termination. only addition, multiplication and degrouping should be counted as operations, not reading or printing. make sure access to this variable is free from race conditions.

ansver
Answers: 1

Another question on Engineering

question
Engineering, 04.07.2019 18:10
Condition monitoring is a major component of. (clo4) a)- predictive maintenance. b)-preventive maintenance c)-proactive maintenance d)-reactive maintenance.
Answers: 1
question
Engineering, 04.07.2019 18:20
The characteristic roots of a dynamic system are: 1.7920 1.8160 i, -1.7920 1.8160 i, -0.4160 what is the order of this system? what are the settling time and damping ratio of the system?
Answers: 3
question
Engineering, 04.07.2019 19:10
What is the chief metrological difference between measuring with a microscope and with an electronic comparator? a. the microscope is limited to small workpieces.a. the microscope is limited to small workpieces. c. the comparator can only examine one point on the workpiece. d. the microscope carries its own standard.
Answers: 1
question
Engineering, 04.07.2019 19:10
Plan an experiment to measure the surface tension of a liquid similar to water. if necessary, review the ncfmf video surface tension for ideas. which method would be most suitable for use in an undergraduate laboratory? what experimental precision could be expected?
Answers: 2
You know the right answer?
Write the code to implement these functions. they should only consider the current expression, which...
Questions
question
Spanish, 18.03.2021 03:50
question
Mathematics, 18.03.2021 03:50
question
History, 18.03.2021 03:50
question
Mathematics, 18.03.2021 03:50
question
Business, 18.03.2021 03:50
Questions on the website: 13722361