CompOrg HW2 FAQ

Homework #2 FAQ

Question:

I'm running on a PC using cygwin and the time command seems to only report the real time (user and sys always show up as 0.0s). What's up?

Answer:

I suspect that under Windows there is no way for the time command to be able to tell the user and system time. Try your program on a real Unix machine!


Question: If I run the time command on my addition program a bunch of times with the same count each time, I get slightly different results each time, shouldn't this be fairly constant?

Answer:

The accuracy of time measurement is not great, and is worse the smaller the actual time values are. So you should expect to see some variation. Use large numbers of iterations so that the total time is much larger than the variations...


Question:

How do I give an integer value (the number of iterations that the add or mult programs should use) to execl()?

Answer:

Each parameter to execl() is a string. execl() does not understand format strings (like "%d"), those are just used by printf (and also scanf). If you have an integer that should be sent to a program (to it's command line args), you must convert it to a string which can then be given to execl().

To convert a int to a string, you can use sprintf(), which works like printf, except that the output is placed in a string instead of being sent to STDOUT. Try man sprintf for details...