Starting from:
$30

$24

Lab 01 Solution

Problem 1:




The first tag declares an int variable named int_var. Int_var has no value assigned to it. The second tag calls the printf function, this is a formatted print function as opposed to just print. This prints out the byte size of the int_var integer variable. It also prints out 8 times the byte size of the int_var variable.



Compute.cse.tamu.edu



Linux.cse.tamu.edu



I did not get the time executed to be negative.



There is a change in the time reported. The values for both times on both servers are now lower than before. I don’t know which of the values is correct but I believe the difference if because the double can hold 8 bits of information vs the 4 bits of information that can be held by the long int.



timeval is a data type that represents elapsed time and it is declared in sys/time.h thus it is a “standard” C data type.



Submit output files



Problem 3:




Boolean Expressions




Requirement 1



(driver_on_seat && engine_running && !driver_seat_belt_fastened) bell = 1



Requirement 2



(driver_on_seat && !doors_closed) bell = 1



Requirement 3



(Requirement 1 || Requirement 2) bell = 1



Requirement 4



!(!driver_on_seat && keys_in_car && door_lock_lever) door_lock_actuator = 0



Requirement 5



(driver_on_seat && brake_pedal && car_moving) brake_actuator = 1



Truth Table:




DOS
DSBF
ER
DC
KIC
DLC
BP
CM


BELL
DLA
BA
























0
0
0
0
X
X
X
X


0
X
X
























0
0
1
0
X
X
X
X


0
X
X
























0
1
0
0
X
X
X
X


0
X
X
























0
1
1
0
X
X
X
X


0
X
X
























1
0
0
0
X
X
X
X


1
X
X
























1
0
1
0
X
X
X
X


1
X
X
























1
1
0
0
X
X
X
X


1
X
X
























1
1
1
0
X
X
X
X


1
X
X
























0
0
0
1
X
X
X
X


0
X
X
























0
0
1
1
X
X
X
X


0
X
X
























0
1
0
1
X
X
X
X


0
X
X
























0
1
1
1
X
X
X
X


0
X
X
























1
0
0
1
X
X
X
X


0
X
X
























1
0
1
1
X
X
X
X


1
X
X
























1
1
0
1
X
X
X
X


0
X
X
























1
1
1
1
X
X
X
X


0
X
X
























0
X
X
X
0
0
X
X


X
1
X
























0
X
X
X
0
1
X
X


X
1
X
























0
X
X
X
1
0
X
X


X
1
X
























0
X
X
X
1
1
X
X


X
0
X
























1
X
X
X
0
0
X
X


X
1
X
























1
X
X
X
0
1
X
X


X
1
X
























1
X
X
X
1
0
X
X


X
1
X
























1
X
X
X
1
1
X
X


X
1
X
























0
X
X
X
X
X
0
0


X
X
0
























0
X
X
X
X
X
0
1


X
X
0
























0
X
X
X
X
X
1
0


X
X
0
























0
X
X
X
X
X
1
1


X
X
0
























1
X
X
X
X
X
0
0


X
X
0
























1
X
X
X
X
X
0
1


X
X
0
























1
X
X
X
X
X
1
0


X
X
0
























1
X
X
X
X
X
1
1


X
X
1



























Problem 4: ​Instead of using the bit masks individually, which could be confusing, you could have an enum class. They way you can use this is if you make specific masks for specific values. This is useful so you don't necessarily have to remember the actual hex value for the mask, you just have to remember the value in the enum class. This would have been useful in my code when I had to go look up the different hex values to use ask masks. If I had made an enum I just had to look up the values once and then I could have saved time looking up the values over and over again. It could also increase maintainability because if you accidentally typed the wrong hex for a mask if you used it multiple times it would be easier to just change it in the enum rather than the find each individual one and change it.

Problem 5:




The execution time for the code in Problem 4 is much faster than the time for the code in Problem 3. On both servers the execution time was significantly faster. It was much faster than I thought was actually possible. I am convinced that the code in Prob 4 is faster to execute. However, the time it took to write it was not faster.



Problem 3 Execution Time Test (First SC is Compute, Second SC is Linux)

























































C.







D. Problem 4 Execution Time Test (First SC is Computer, Second SC is Linux)
































































E.

More products