Docsity

Operating Systems Principles Homework 0: Evaluation of Prerequisite Knowledge, Assignments of Algorithms and Programming

Toggle sidebar
bg1
CSCE 451/851 Operating Systems Principles
Fall 1999
Steve Goddard
Homework 0, August 24
Evaluation of prerequisite knowledge
Due: 2:00pm August 31
____________________________________________________________
The prerequisites for CSCE 451/851 are CSCE 231 and 310. This purpose of this
assignment is to evaluate your understanding of the prerequisite knowledge. You may
consult any textbook or other resource to complete the assignment, but do the work on
your own. This is not a group project.
CSCE 231 (and 230 by transitivity)
1) How is the decimal number 49 represented in
A) Binary?
B) Octal?
C) Hexadecimal?
D) Base 7?
Try to do this one without a calculator :)
2) Why should the value of the program counter be updated before an instruction is
executed? (Hint: What instructions change the value of the program counter as part
of their execution? Would it make a difference if the program counter were updated
after these instructions had been “performed?”)
3) What addressing mode would you use if you wanted to implement a stack in
assembly language? Why?
4) Suppose procedure A calls procedure B, and procedure B calls procedure C. Assume
that register R5 is used for linking; that is, register R5 contains the address by which
any called procedure returns to its calling procedure. What must procedure B do so
that it can send a return address to C without losing the return address it needs to
return to A? Give the assembly instructions by which B could do this.
pf3
pf4
pf5

Partial preview of the text

Download Operating Systems Principles Homework 0: Evaluation of Prerequisite Knowledge and more Assignments Algorithms and Programming in PDF only on Docsity!

CSCE 451/851 Operating Systems Principles

Fall 1999

Steve Goddard

Homework 0, August 24

Evaluation of prerequisite knowledge

Due: 2:00pm August 31

____________________________________________________________

The prerequisites for CSCE 451/851 are CSCE 231 and 310. This purpose of this assignment is to evaluate your understanding of the prerequisite knowledge. You may consult any textbook or other resource to complete the assignment, but do the work on your own. This is not a group project.

CSCE 231 (and 230 by transitivity)

  1. How is the decimal number 49 represented in A) Binary? B) Octal? C) Hexadecimal? D) Base 7? Try to do this one without a calculator :)
  2. Why should the value of the program counter be updated before an instruction is executed? ( Hint : What instructions change the value of the program counter as part of their execution? Would it make a difference if the program counter were updated after these instructions had been “performed?”)
  3. What addressing mode would you use if you wanted to implement a stack in assembly language? Why?
  4. Suppose procedure A calls procedure B, and procedure B calls procedure C. Assume that register R5 is used for linking; that is, register R5 contains the address by which any called procedure returns to its calling procedure. What must procedure B do so that it can send a return address to C without losing the return address it needs to return to A? Give the assembly instructions by which B could do this.
  1. Consider the following state of a MIPS R2000 machine: RegisterRegister 56 containscontains (^10002000) RegisterMemory location 7 contains 1000 3000 contains 2000 MemoryMemory locationlocation 20003000 containscontains (^30001000) All numbers are in octal (base 8) notation. After the following three R2000 assembly instructions are executed from the above initial state, what is the state of the machine? That is, show the contents of regisers 5, 6, and 7 as well as memory locations 1000, 2000, and 3000. ADDILW $5,$7, $6,0($5) 1000 LWADDI $5,$6, 0($5)$7, 1000 ADD $7, $6, $ Keep all numbers in octal (base 8) notation.
  2. Differentiate between “linking” and “loading” a program. The following questions are exercises from the end of Chapter 2 of the text for this class. This material is also considered prerequisite knowledge; hence, it was not covered in class.
  3. What are the differences between a trap and an interrupt? What is the use of each function?
  4. What is DMA, and for what types of operations is DMA useful? Explain your answer.
  5. When are caches useful? What problems do they solve? What problems do they cause? If a cache can be made as large as the device for which it is caching (for instance, a cache as large as a disk), why not make it that large and eliminate the device?
  6. Writing an operating system that can operate without interference from malicious or undebugged user programs requires some hardware assistance. Name three hardware aids for writing an operating system.

Consider the following definitions for functions that operate on a stack S. A) MAKENULL(S). Make stack S be an empty stack. B) EMPTY( S ). Return true if S is an empty stack; return false otherwise. C) TOP( S ). Return the element at the top of stack S. The element is not deleted from the stack. D) POP( S ). Delete the top element of stack S. E) PUSH( x, S ). Insert x at the top of stack S. The old top element becomes next- to-top, and so on.

  1. Show the stack created by the following commands MAKENULL(S);PUSH(p,S); PUSH(u,S);PUSH(s,S); PUSH(h,S);POP(S); PUSH(TOP(S),S);PUSH(s,S); PUSH(TOP(S),S);PUSH(u,S); PUSH(p,S);

Consider the following tree:

1 4) Answer the following questions about the tree. A) Which nodes are leaves? B) Which node is the root? C) What is the parent of node B? D) Which nodes are children of B? E) Which nodes are ancestors of G? F) Which nodes are descendants of G? G) What are the siblings of G and E? H) Which nodes are to the left and to the right of J? I) What is the depth of node M? J) What is the height of node M?

  1. List the nodes of the tree in a) preorder, b) postorder, and c) inorder.