Introduction to Operating Systems - Assignment 1 | COP 4600, Assignments of Operating Systems

Material Type: Assignment; Class: Operating Systems; Subject: Computer Programming; University: University of Central Florida; Term: Spring 2009;

Typology: Assignments

Pre 2010

Uploaded on 02/24/2010

koofers-user-cup
koofers-user-cup 🇺🇸

10 documents

1 / 15

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
1
1. (30 points)
Using the hypothetical machine from the lecture notes (Hardware Considerations
pages 12-17). Assume that we have the following instruction set:
Binary Opcode
Instruction Semantics
0001
Load AC from memory address
0010
Store AC to memory address
0011
Load AC from I/O device
0100
Right shift AC 1 bit
0101
Add to AC from memory address
0110
Multiply to AC from memory address
0111
Store AC to I/O device
For instructions that access I/O devices, they I/O device is treated similar to memory in
that the 12-bit address identifies a particular external device. Using a technique similar
to that used in the notes, show the step-by-step execution of the following program.
All addresses are given in hexadecimal. Assume the following:
1. The program is loaded starting at address 300.
2. The next value retrieved from device 5 is 3.
3. Memory location 840 contains the value E.
4. Memory location 841 contains the value B.
The program in hexadecimal:
3005
5840
7006
1841
4000
5840
2842
COP 4600 Introduction To Operating Systems Summer 2009
Homework #1 130 points
KEY
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff

Partial preview of the text

Download Introduction to Operating Systems - Assignment 1 | COP 4600 and more Assignments Operating Systems in PDF only on Docsity!

  1. (30 points) Using the hypothetical machine from the lecture notes (Hardware Considerations pages 12-17). Assume that we have the following instruction set:

Binary Opcode Instruction Semantics 0001 Load AC from memory address 0010 Store AC to memory address 0011 Load AC from I/O device 0100 Right shift AC 1 bit 0101 Add to AC from memory address 0110 Multiply to AC from memory address 0111 Store AC to I/O device

For instructions that access I/O devices, they I/O device is treated similar to memory in that the 12-bit address identifies a particular external device. Using a technique similar to that used in the notes, show the step-by-step execution of the following program. All addresses are given in hexadecimal. Assume the following:

  1. The program is loaded starting at address 300.
  2. The next value retrieved from device 5 is 3.
  3. Memory location 840 contains the value E.
  4. Memory location 841 contains the value B.

The program in hexadecimal: 3005 5840 7006 1841 4000 5840 2842

COP 4600 – Introduction To Operating Systems – Summer 2009

Homework #1 – 13 0 points

KEY

SOLUTION

Initial memory initial CPU registers ADDRESS (in hex)

VALUE

(in hex) 300 3005 301 5840 302 7006 303 1841 304 4000 305 5840 306 2842

...... 840 000E 841 000B 842?

REGISTER

VALUE

(in hex) PC?

AC?

IR?

ADDRESS

(in hex)

VALUE

(in hex) 5 0003 6?

Initial device values

Instruction #2: Add contents of address 840: (5840) 16 = (0101 1000 0100 0000) 2

FETCH/DECODE STEP:

Initial memory initial CPU registers

EXECUTE STEP:

Initial memory initial CPU registers

ADDRESS

(in hex)

VALUE

(in hex) 300 3005 301 5840 302 7006 303 1841 304 4000 305 5840 306 2842

...... 840 000E 841 000B 842?

REGISTER

VALUE

(in hex) PC 301

AC 0003

IR 5840

ADDRESS

(in hex)

VALUE

(in hex) 5 0003 6?

ADDRESS

(in hex)

VALUE

(in hex) 300 3005 301 5840 302 7006 303 1841 304 4000 305 5840 306 2842

...... 840 000E 841 000B 842?

REGISTER

VALUE

(in hex) PC 302

AC 0011

IR 5840

ADDRESS

(in hex)

VALUE

(in hex) 5 0003 6?

Initial device values

Initial device values

3 + E = 11

Instruction #3: Store AC to device 6: (7006) 16 = (0111 0000 0000 0110) 2

FETCH/DECODE STEP:

Initial memory initial CPU registers

EXECUTE STEP:

Initial memory initial CPU registers

ADDRESS

(in hex)

VALUE

(in hex) 300 3005 301 5840 302 7006 303 1841 304 4000 305 5840 306 2842

...... 840 000E 841 000B 842?

REGISTER VALUE

(in hex) PC 302

AC 0011

IR 7006

ADDRESS

(in hex)

VALUE

(in hex) 5 0003 6?

ADDRESS

(in hex)

VALUE

(in hex) 300 3005 301 5840 302 7006 303 1841 304 4000 305 5840 306 2842

...... 840 000E 841 000B 842?

REGISTER

VALUE

(in hex) PC 303

AC 0011

IR 7006

ADDRESS

(in hex)

VALUE

(in hex) 5 0003 6 0011

Initial device values

Initial device values

Instruction #5: Right Shift AC: (4000) 16 = (0100 0000 0000 0000) 2

FETCH/DECODE STEP:

Initial memory initial CPU registers

EXECUTE STEP:

Initial memory initial CPU registers

ADDRESS

(in hex)

VALUE

(in hex) 300 3005 301 5840 302 7006 303 1841 304 4000 305 5840 306 2842

...... 840 000E 841 000B 842?

REGISTER VALUE

(in hex) PC 304

AC 000B

IR 4000

ADDRESS

(in hex)

VALUE

(in hex) 5 0003 6 0011

ADDRESS

(in hex)

VALUE

(in hex) 300 3005 301 5840 302 7006 303 1841 304 4000 305 5840 306 2842

...... 840 000E 841 000B 842?

REGISTER

VALUE

(in hex) PC 305

AC 0005

IR 4000

ADDRESS

(in hex)

VALUE

(in hex) 5 0003 6 0011

Initial device values

Initial device values

Instruction #6: Add AC from address 840: (5840) 16 = (0101 1000 0100 0000) 2

FETCH/DECODE STEP:

Initial memory initial CPU registers

EXECUTE STEP:

Initial memory initial CPU registers

ADDRESS

(in hex)

VALUE

(in hex) 300 3005 301 5840 302 7006 303 1841 304 4000 305 5840 306 2842

...... 840 000E 841 000B 842?

REGISTER VALUE

(in hex) PC 305

AC 0005

IR 5840

ADDRESS

(in hex)

VALUE

(in hex) 5 0003 6 0011

ADDRESS

(in hex)

VALUE

(in hex) 300 3005 301 5840 302 7006 303 1841 304 4000 305 5840 306 2842

...... 840 000E 841 000B 842?

REGISTER

VALUE

(in hex) PC 306

AC 0013

IR 5840

ADDRESS

(in hex)

VALUE

(in hex) 5 0003 6 0011

Initial device values

Initial device values

5 + E = 13

  1. (10 points) A computer has a cache, a main memory, and a disk used for virtual memory. If a referenced word is in the cache, 20 ns are required to access it. If it is in the main memory but not in the cache, 60 ns are needed to load it into the cache (this includes the time required to originally check the cache), and then the reference is started again. If the word is not in main memory, 12 ms are required to fetch the word from disk, followed by 60 ns to copy it to the cache, and then the reference is started again. The cache hit ratio is 0.9 (i.e., the probability that the referenced word is in the cache is 90%) and the main memory hit ratio is 0.6 (i.e., the probability that the referenced word is in the main memory is 60%).

What is the average time in nanoseconds required to access a referenced word on this computer?

SOLUTION

There are three cases to consider:

Location of the referenced word

Probability Total time for access in nanoseconds In cache 0.9 20ns Not in cache, but in main memory (0.1)(0.6) = 0.06^ 60ns + 20ns = 80ns Not in cache and not in main memory (0.1)(0.4) = 0.04^ 12ms + 60ns + 20ns = 12,000,080ns

So the average access time would be:

= (0.9)(20ns) + (0.06)(80ns) + (0.04)(12000080ns) = 480,026ns

  1. (90 points – 15 points each (a)-(f)) Consider the set of processes shown in the table below.

Process Arrival Time Processing Time A 0 3 B 1 5 C 3 2 D 9 5 E 12 5

For each of the scheduling protocols of (a) FCFS, (b) Round-Robin (do for both time- quantum = 1 and time quantum = 2), (c) Shortest Process Next, (d) Shortest Remaining Time, (e) HRRN, and (f) Feedback (time-quantum = 1) do the following:

  1. Generate the Gantt chart showing the execution order/timing of these processes.
  2. Determine the average waiting time for a process.
  3. Determine the average turnaround time for a process.
  4. Determine the normalized turnaround time for a process.

RR (quantum = 2) Gantt chart:

A B C D E

Timing Process Waiting Time Tr Tr/Ts A 4 7 7/3 = 2. B 6 11 11/5 = 2. C 1 3 3/ 1 = 3 D 5 10 10/5 = 2 E 4 8 8/ 4 = 2

Mean 20/5 = 4 39/5 = 7.8 11.53/5 = 2. 306

(c) SPN Gantt chart:

A

B

C

D

E

Timing

Process Waiting Time Tr Tr/Ts

A 0 3 3/3 = 1 B 4 9 9/5 = 1. C 0 2 2/2 = 1 D 1 6 6/5 = 1. E 3 8 8/5 = 1. Mean 8/5 = 1.6 28/5 = 5.6 6.6/5 = 1.

0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20

0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20

(d) SRT Gantt chart A B C D E

Timing Process Waiting Time Tr Tr/Ts

A 0 3 3/3 = 1 B 4 9 9/5 = 1. C 0 2 2 /2 = 1 D 1 6 6/5 = 1. E 3 8 8/5 = 1. Mean 8/5 = 1.6 28/5 = 5.6 6.6/5 = 1. 32

(e) HRRN (assume FCFS in event of tie on HRR) Gantt chart A B C D E

Timing Process Waiting Time Tr Tr/Ts A 0 3 3/3 = 1 B 2 7 7/5 = 1. C 5 7 7/2 = 3. D 1 6 6/5 = 1. E 3 8 8/5 = 1. Mean 11/5 = 2.2 31/5 = 6.2 8.7/5 = 1.

0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20

0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20