Question: 2. Consider the program given below: 1 void testFn (int *x, int flag) while (flag != 1) { flag = 1; *x = flag; 6

 2. Consider the program given below: 1 void testFn (int *x,

2. Consider the program given below: 1 void testFn (int *x, int flag) while (flag != 1) { flag = 1; *x = flag; 6 if (*x > 0) *x += 2; In answering the questions below, assume that x is not NULL. (a) Draw the control-flow graph of this program. Identify the basic blocks with unique IDs starting with 1. Lee & Seshia, Introduction to Embedded Systems 455 EXERCISES Note that we have added a dummy source node, numbered 0, to represent the entry to the function. For convenience, we have also introduced a dummy sink node, although this is not strictly required (b) Is there a bound on the number of iterations of the while loop? Justify your (c) How many total paths does this program have? How many of them are feasi (d) Write down the system of flow constraints, including any logical flow con- (e) Consider running this program uninterrupted on a platform with a data cache. answer ble, and why? straints, for the control-flow graph of this program Assume that the data pointed to by x is not present in the cache at the start of this function. For each read/write access to x, argue whether it will be a cache hit or miss Now, assume that x is present in the cache at the start of this function. Iden- tify the basic blocks whose execution time will be impacted by this modified assumption

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!