Problem 1

Register -

1024 pages x 2400 x 1e-9 = 2.4576 ms

Cache

1024 x 2400 x 2e-9 = 4.9152 ms

Main Memory

1024 x 2400 x 10e-9 = 24.576 ms

Disk

1024 x 2400 x 10e-3 / 4096 = 6 sec

Tape

100 + 1024 x 2400 x 10e-3 / 4096 = 106 sec


Problem 2

A TRAP is an interrupt that is CPU or user process-initiated. It is still an interrupt and is handled by an interrupt handler. TRAP may be used to switch into kernel mode (traps have numbers, and only one of these numbers is for a system call, other numbers may be for other things), and interrupt is used by a device to tell the CPU that a job is completed. An example of a TRAP is one caused by division by zero and an example of an interrupt is characters arriving as input from the keyboard.


Problem 3

L1 cache memory is a level of memory that is closest to the CPU and can therefore be accessed quicker than any other level. It typically resides on the CPU chip. The L2 cache is a level further from the CPU and typically resides on another chip. It is however still quicker to access than main memory. Cache may improve performance but the by increasing the size of the cache one will also increase the access time. The more the address space in a cache, the more complicated is the IC circuitry, and the higher the delay in response from the cache.


Problem 4

The "absolutely necessary" instructions are 2, 4, 7, and 5.

2 - No user process should be able to gain access to kernel mode by distinction and definition of user and kernel processes

4 - Same reason as #2. Errors or malicious processes could seriously compromise or undermine the integrity of the system.

5 - User processes should not be able to execute OS code.

7 - This would allow user processes to take control over the CPU.


Problem 5

1. A Trap is invoked to switch into kernel mode. The state of the previously running thread is stored into the kernel thread table. The kernel thread table is examined for a ready thread. The next thread may be from the current process or another process. The thread's registers and state are loaded and the thread is run. The system switches back to user mode.

2. The state of the previously running thread is stored into the thread table. The thread table is examined for a ready thread. The thread's registers and state are loaded and the thread is run.


Problem 6

Kernel-level, otherwise a single long interrupt at the server can cause all clients to hang or wait.


Problem 7

pid - The system nees to be able to distingish one task from another. (A)

state - a, b or c will be accepted

priority - a b or c will be accepted

policy - a b or c will be accepted

start_time - The parent and child do not start at the same time. (A)

uid, gid - both of these should remain the same as both belong to the same user. (B)

tss - the child task will have its own state and thus will change. (A)

files - since the are in the same address space, they share all resources such as files. (B)

mm - They share the same address space and thus the same code and data. (B)


Problem 8.

Average Waiting Time and Average Turnaround Time with one CPU

Start Process
0 3
3 50
53 12
65 39
104 20
124 21
145 1
146 4

 

Avg. Waiting Time = (0 + 3 + 53 + 65 +104 + 124 + 145 + 146) / 8 = 80 time units

Avg. Turnaround Time = (3 + 53 + 65 + 104 + 124 + 145 + 146 + 150) / 8 = 98.75 time units

 

Average Waiting Time and Average Turnaround Time with two CPUs

Start End Process CPU
0 3 3 1
0 50 50 2
3 15 12 1
15 54 39 1
50 70 20 2
54 75 21 1
70 71 1 2
71 75 4 2

Avg. Waiting Time = (0 + 0 + 3 + 15 + 50 + 54 + 70 + 71) / 8 = 32.875 time units

Avg. Turnaround Time = (3 + 50 + 15 + 54 + 70 + 75 + 71 + 75) / 8 = 51.625 time units

If one CPU is tied up with a computationally intensive process then the queue of processes ends up relying on the other processor and reduces the parallelism of the system.