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
Afour cylinder four-stroke in-line engine has a stroke of 160mm, connecting rod length of 150mm, a reciprocating mass of 3kg and its firing order is 1-3-4-2. the spacing between cylinders is 100mm. i. show that the engine is in balance with regard to the primary inertia forces and primary 3. a and secondary inertia couples. li determine the out of balance secondary inertia force ii. propose ways of balancing this out of balance force and discuss the challenges that will arise
Answers: 3
question
Engineering, 04.07.2019 18:10
The thermal expansion or contraction of a given metal is a function of the f a)-density b)-initial temperature c)- temperature difference d)- linear coefficient of thermal expansion e)- final temperature f)- original length
Answers: 2
question
Engineering, 04.07.2019 18:10
Journeyman training is usually related (clo2) a)-to specific tasks b)-to cost analysis of maintenance task c)-to control process to ensure quality d)-to installation of machinery
Answers: 2
question
Engineering, 04.07.2019 18:20
Acertain flow of air (at stp) has a velocity distribution given by v i (in ft/s). if this flow is going through a 4 ft square area in the yz-plane (centered at the origin), what is the mass flow rate (in lbm/s)?
Answers: 2
You know the right answer?
Write the code to implement these functions. they should only consider the current expression, which...
Questions
question
Mathematics, 03.09.2020 01:01
question
Mathematics, 03.09.2020 01:01