Exercises
Computer Organization I, HW 5
- Subroutines, macros, literals, variables, constants
- Give an example of a situation where routine XYZ would be better to implement as a macro than as a subroutine. Why? Example?
- Give an example of a situation where routine XYZ would be better to implement as a subroutine than as a macro. Why? Example?
- Give an example of a situation where constant value X would be better to implement as a literal than as a constant in the instruction. Why? Example?
- Give an example of a situation where constant value X would be better to implement as a constant in the instruction than a literal. Why? Example?
- How does using a literal differ from using a variable? Advantages? Disadvantages?
- How does using a literal differ from using constant field? Advantages? Disadvantages?
- Parameters
- Give an example on a situation where a parameter may be passed as call-by-value or call-by-reference parameter.
- Give an example on a situation where it is sensible to use call-by-value but not call-by-reference parameter.
- Give two inherently different cases whete a parameter must be passed as call-by-reference parameter. Why can one not use call-by-value parameters in these cases?
- Why is it good to use call-by-name parameters with macros, and not call-by-value or call-by-reference parameters.
- Why do high level languages (e.g., Java or C) usually not have call-by-name parameters?
- Assume that a disk spins with speed 7200 rpm, it has one read/write head
per surface, there are 2000 cylinders (tracks per surface), each track has
50 sectors, and sector size is 0.5 KB. Assume (unrealistically), that seek
time (head transfer time) is linear to the number of tracks passed, and that
it is 0.02 ms/track. Assume (unrealistically), that the location of each
sector for one file is random, and from this one can deduce (with
probability theory) that the average number of tracks passed is 667. Assume
further (unrealistically), that the file is read from the disk one sector at
a time.How long does it take, in average, to read one 333.33 KB file? What
about 24 MB file?
- Linking.
- How would the Fig 7-15 (b) in Tanenbaum book [Tane99] change, if the modules were linked (from bottom up) in order ACDB instead of the order ABCD used in Fig. 7-15?
Please note that the addresses grow bottom-up in Fig. 7-15. Modules are defined in Fig 7-14.
- What should one modify in modules A, B C, and D, if one would start using an updated version of module B? Can one run the update when the program containing those modules was in the middle of execution? Why?
- Memory mapped I/O. In the example driver.k91 there is a device driver implemented with direct I/O.
- How does the device driver know that the device has printed the given number?
- What does the device driver do while the device is printing the number?
How long can this take?
- How does the device (device controller) tell the device driver that the given task is done?
- Hoe does the application program (that called the device driver) know when the task given to the device is done?
- How should one modify the device driver, if one wanted to use indirect I/O instead? The purpose is not to give a precise answer, but just the general ideas on what needs to be changed in the driver in case indirect I/O was used.
What is good/bad with this change? Are there any changes to the specifications for the device (device controller) because of this change.
- Do level D TitoTrainer problems d-200, d-300, d-310 ja d-400