Engineering
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.

answer
Answers: 1

Other questions on the subject: Engineering

image
Engineering, 03.07.2019 14:10, kayabwaller4589
When at a point two solid phase changes to one solid phase on cooling then it is known as a) eutectoid point b) eutectic point c) peritectic point d) peritectoid point
Answers: 3
image
Engineering, 04.07.2019 16:10, TheOriginalMeyah
An electrical motor raises a 50kg load at a construct velencity .calculate the power of the motor, if it takes 40sec to raise the load through a height of 24m(take g =9.8n/g)
Answers: 2
image
Engineering, 04.07.2019 18:10, koolgurl2003
Apump is used to circulate hot water in a home heating system. water enters the well-insulated pump operating at steady state at a rate of 0.42 gal/min. the inlet pressure and temperature are 14.7 lbf/in.2, and 180°f, respectively; at the exit the pressure is 60 lbf/in.2 the pump requires 1/15 hp of power input. water can be modeled as an incompressible substance with constant density of 60.58 lb/ft3 and constant specific heat of 1 btu/lb or. neglecting kinetic and potential energy effects, determine the temperature change, in °r, as the water flows through the pump.
Answers: 1
image
Engineering, 04.07.2019 18:10, Talos02
Burgers vector is generally parallel to the dislocation line. a)-true b)-false
Answers: 2
Do you know the correct answer?
Write the code to implement these functions. they should only consider the current expression, which...

Questions in other subjects:

Konu
History, 27.01.2021 19:30