Assignment 1
Comp 3730
Note: you are NOT
allowed to re-copy text from the book, the Internet, other teams or other
sources in your answers. You must use your own words and clearly express
your answer, showing that you understand it. Otherwise, you will get a mark of
0 for that question.
You are allowed
to work with one partner. No teams of three or more are allowed.
The assignment should be handed-in no later than January 19 at 12:30 in
the assignment box of your lab instructor.
No late assignments will be accepted. (12:35 is late!)
1.
a) Consider the
idea of running another operating system on a virtual computer, that is,
running an operating system as a program on another operating system. There are two ways we could do this. Discuss each one in terms of practicality
and efficiency. [10]
·
Load the operating system code directly into the virtual computer (with
no other additional software) and run it. This OS will only be able to use the
instructions and system calls allowed by the underlying OS.
·
You first load an emulator into the virtual computer. The emulator
creates a virtual version of some computer.
Then you load the operating system to run on this emulator.
b) What protection
mechanisms are needed when implementing virtual machines? [5]
2.
a) What is the
alternative to memory-mapped I/O? [5]
b) You have just been hired
by Intel to work on the development of the new Pentium chip. The problem that
you are asked to solve is as follows: To optimize performance, the processor
currently allows cacheable memory reads to be reordered ahead of buffered
writes. I.e. a memory write that comes before a memory read in a program
is actually executed after. The problem is that with memory-mapped I/O,
you may try reading the status of a device after a write, but you end up
with the device status before the write is performed.
Your job is to design two solutions that will force the processor to execute
the program instructions in the order specified by the programmer. Describe
your solutions. [10]
Hint: answers can be found
on http://developer.intel.com/design/intarch/techinfo/Pentium/
3.
a) The interval
timer only counts down to zero. Suppose
we wanted to keep the time of day. How
could we use the interval timer to keep the time of day? [5]
b) Some
processors save the ia register and
the psw register on a stack when an
interrupt occurs. What are the
advantages and disadvantages of this? [5]
c) When executing an RTI
instruction, first the contents of the iia register are moved to the ia
register, and then the content of the ipsw register is moved to the psw
register. Is the order of those instructions important? Why? [5]
d) Suppose a
computer did not have a special system call instruction but it did have a
typical interrupt system. How could you
simulate a system call instruction on such a computer? [8]
4.
a) Suppose we
wanted to implement a linked data structure in a disk file rather than in
memory. Explain how you would use the read, write and lseek system calls to
do this. [8]
b) Write a
program using the file system calls (open, creat, read, write, lseek, close,
unlink) that determines the length of a file without using a loop in the code.
[5]
c) Using the same file
system calls, how can a programmer determine the current file position of an
open file? [5]
5.
a) What are the
advantages of named pipes (with names in the file system) over pipes with
internal names? Are there any
disadvantages? [5]
b) In order for two
processes to communicate by messages, they both have to know the qid of the
message box that they will be using. This qid is normally passed to each
process from their common parent. What could the OS designer do to allow two
processes with no common parent communicate? i.e. how can they communicate the
common qid? Describe three distinct solutions. [9]
6.
a) If you want to include an
assembly language routine in a C++ program other than using an asm block, what
do you need to do? [5]
b) Crowley describes the
following system call:
int
write( int openFileID, char * bufferAddress, int count);
Suppose that you make a write() system call and
that no errors occur. Can write() return a value
different than count? Explain. [5]
c) On page 69, the shell
program is declared as follows:
void
main (int argcount, char *arguments[ ])
What arguments might be passed to a shell? [5]