Be prepared to show all Koksi related and other programming homeworks
using a PC at the practice session. Please bring both a listing and on a
diskette all the programs you made for this practice session.
Alternatively to bringing the diskette, you can store your programs to the fs file server.
- Question 1: Duration of disk operations
Return the answer to this question day before your meeting!
This answer will grant you one point equal to the points of the course exam.
Let us assume the following information about the disk system:
- The 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 a sector size is 0.5 kB.
- The seek time (head transfer time) is linear to the number of tracks
passed, and it is assumed to be 0.02 ms/track.
- 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.
- 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?
Write your answer (formulas, different phases of calculations) to a plain text file,
which you must then send to the
course assistant using the web-page
http://db.cs.helsinki.fi/~tuohinie/tito/ .
The web-page asks first you to choose your small group. Then you have to
write your name and upload the text file containing your report.
You have to return the answer at the latest 24 hours before the
small group session's starting time.
A late delivery is not possible.
- Question 2: Subroutines, macros, literals, variables, constants
The programmer while writing a program can also think about the future
work of a compiler. Certain solutions could be more suitable for the
compiler or the final machine language than some others.
- How does using a literal differ from using a variable? Advantages?
Disadvantages?
- How does using a literal differ from using constant field?
Advantages? Disadvantages?
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.
Give an example of a situation where constant value X would be
better to implement as a constant in the instruction than a literal.
- How does using a macro differ from using a subroutine?
Advantages? Disadvantages?
Give an example of a situation where routine XYZ would be better
to implement as a macro than as a subroutine.
Give an example of a situation where routine XYZ would be better
to implement as a subroutine than as a macro.
- Question 3: Name binding
Binding a name given in a program to its final value can occur at least
during the following phases: when program is written, during
compilation, during linking, during loading, during base register
loading, or during instruction execution time. When does the binding
occur for the following examples? Give reasoning.
| Operation | Names |
a. | add R1,ParX(FP) |
R1? ParX? FP?
ADD? |
b. | XX dc 456789 | XX? |
c. | call SP, IO.Print |
Print? |
d. | DD equ 65 | DD? |
e. | locX = 3456789; |
locX? variable of c language |
In each case, give reasoning why the binding can not occur sooner or later.
- Question 4: Self-modifying code
What does the program
mystery.k91 do? How does it do that? What about program
mystery2.k91? How does it do that? What benefits one could (hope to) get from
this kind of programming style? What problems would there be?
- Question 5: Linking
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.
- Question 6: Memory mapped I/O.
In example
HREF="http://www.cs.helsinki.fi/u/kerola/tito/esimerkit/driver.k91">
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?
- How does the application program (that call 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 driver) because of this
change?
Tiina.Niklander@cs.helsinki.fi