This program is intended to provide understanding in the areas of interrupts and exception handling.
Reuse the user-level program from program 4 together with an interrupt-driven kernel. Add code to the user-level program that times and prints out the number of seconds it takes the user to type the alphabet each time. Also add code to identify in which run the user entered the input faster. As for Program 4, if the number of seconds is the same for both runs, the program states that test number 1 took less time.
The user input is shown in bold. All other display is generated by the program.
Typing test: Type the string exactly as seen,
followed by the return key when finished.
abcdefghijklmnopqrstuvwxyz
aaadefghijklmnopqrstuvwxyz
^^
Number of errors: 2
Number of seconds to take the test: 9
Repeat the test:
abcdefghijklmnopqrstuvwxyz
abcdefghijklmnopqrstuvwxyz
Number of errors: 0
Number of seconds to take the test: 12
The better score was on test number 2
Input was faster on test number 1
Typing test: Type the string exactly as seen,
followed by the return key when finished.
abcdefghijklmnopqrstuvwxyz
aaaaa
^^^^^^^^^^^^^^^^^^^^^^^^^
Number of errors: 25
Number of seconds to take the test: 3
Repeat the test:
abcdefghijklmnopqrstuvwxyz
abcdefghijklmnopqrstuvwxyzZZZ
Number of errors: 3
Number of seconds to take the test: 21
The better score was on test number 2
Input was faster on test number 1
This program uses the user-level program saved from Program 4 together with an interrupt-driven kernel. The interrupt-driven kernel is provided for you in the file
/p/course/cs354-common/public/bin/interrupt.kernel
This interrupt-driven kernel already handles the I/O syscalls
putc,
getc,
and
puts, as well many interrupts.
Copy the file (to your own directory), and modify your copy.
The simulator includes one more I/O device that we call the clock.
This device sends regular interrupts at the rate of one each
second.
The provided kernel works as is, but it is missing the code to handle
interrupts from this clock.
You must write the code within the kernel to handle clock interrupts.
The clock is handled like any other I/O device.
The memory mapped I/O location ClockStatus
works the same way as all the other device status words.
Your kernel implementation uses the clock interrupts to generate
a representation for how much time has passed.
This is a simplified version of system time.
Since the user-level program needs access to timing information,
utilize the generality of the syscall instruction to
add a new function for syscall.
This new type of syscall
is to return the elapsed time (in seconds)
since the the program began running.
Use the value 15 in register $2 ($v0) as a function number for this
new syscall.
#################################
# ADDED KERNEL CODE
# END OF ADDED KERNEL CODE
#################################
__start
the following instruction:
__start: mtc0 $0, $12 # Initialization code to turn off all interrupts.
While interrupts can later be enabled by a similar instruction, this
should be thought of as a debugging tool, and should not appear in
your final code. (This is a privileged instruction, and should not appear
in user-level code. Also note that this instruction technically should
not work in the simulator, since an attempt to execute a privileged
instruction from within a user-level program should cause a trap.)
Turn in your combined kernel and user-level MAL program by running the script:
handinP5 program5.s
where program5.s is an example name of the file
containing the program.
The handinP5 script submits your program for you. No printout will be turned
in.