QUIZ 2 Answers
1 Suppose registers E and F contained (AA)hex and (CC)hex, respectively. What bit pattern would be in register D after executing each of the following instructions (see appendix)?
A. 7DEF __________ B. 8DEF __________ C. 9DEF __________ Answer: A: (EE)hex
1 Opcode 7 means OR the bit patterns in registers… (see textbook Appendix C page 552)
2 Convert (AA)hex to binary presentation: 10101010 3 Convert (CC)hex to binary presentation: 11001100 4 The result of OR operation is 11101110, which is (EE)hex B: (88)hex
1Opcode 8 means ADD the bit patterns in registers… (see textbook Appendix C page 552)
2 Convert (AA)hex to binary presentation: 10101010 3 Convert (CC)hex to binary presentation: 11001100 4 The result of ADD operation is 10001000, which is (88)hex C: (66)hex
1Opcode 9 means EXCLUSIVE OR the bit patterns in registers… (see textbook Appendix C page 552)
2 Convert (AA)hex to binary presentation: 10101010 3 Convert (CC)hex to binary presentation: 11001100 4The result of OR operation is 01100110, which is (66)hex 2 The following is a routine encoded in the machine language described in the language description table. Explain (in
a single sentence) what the routine does. (Explain what the entire routine does as a unit rather than reciting what each instruction does.)
210F 12A0 8212 32A0 Answers:
Opcode 2 means load the register with a bit pattern (see textbook Appendix C page 551). Therefore, 210F means load the register 1 with (0F)hex.
Opcode 1 means load the register with the bit pattern in a memory cell (see textbook Appendix C page 551). Therefore, 12A0 means load the register 2 with the bit pattern stored in memory cell A0.
Opcode 8 means ADD the bit patterns in registers (see textbook Appendix C page 552). Therefore, 8212 means ADD the bit pattern stored in register 1 and 2, and store the result in register 2.
Opcode 3 means STORE the bit patterns to a memory cell (see textbook Appendix C page 552). Therefore, 32A0 means store the bit pattern stored in register 2 into memory cell A0. Of course the exact value is unknown.
3 Using the machine language described in the appendix, write a sequence of instructions that will place a 1 in the most significant bit of the memory cell at address A0 without disturbing the other bits.
Answers:
First, let’s think about how to place a 1 in the most significant bit of a bit pattern. The most significant bit is the left-
most bit of the bit pattern (defined within our course). We are not aware of its state (0 or 1), but we only have to assure its value being 1 after the operation.
As a result, we adopt masking technique (referring to chapter 2). If we design a mask with its most significant bit being 1, e.g. 1xxxxxx… (x represent 0 or 1), then we employ OR operation to “OR” the bit pattern with the mask. Then the most significant bit will be 1, correct? Let’s move on, the question reads: “without disturbing the other bits”, which means the previous operat ion should not change any bit except the most significant one. Finally we see that our mask should be 100000…
So, the answer is: (Assume we use 8 bits)
First, 2180 – load register 1 with 1000000.
Second, 12A0 – load register 2 with bit pattern stored in memory cell A0.
Then, 7312 –store register 3 with the result of “OR” 1 and 2.
The last, 33A0 – write the result back.
4 What information is contained in the state of a process? Answers:
Briefly speaking, the state of a process (in the context perspective) contains the process identification, the value of registers of this process (program counter and generic registers) and the related data in the main memory, I/O and files etc.
5 Since each area on a computer’s display can be used by only one process at a time (otherwise the image on the screen would be unreadable), these areas are nonshareable resources that are allocated by the window manager. Which of the three conditions necessary for dead lock does the windows manager
remove in order to avoid deadlock?
Answers:
The three conditions than “contribute” to deadlock are “Competition for non-sharable resources; resources requested on a partial basis; an allocated resource can not be forcibly retrieved” (referring the textbook page 127).
Therefore, in the circumstance described in the question, the first condition needs to be broken will be described as “Do not allow the overlapping of windows” or “each window should use its own area of the display” etc.
The second condition needs to be broken can be described as “Do not allow the changing of the size of a window and the location of the window” or “Each window should only show up in a fixed area” etc.
The last condition is as simply as “The user can close a window”.
因篇幅问题不能全部显示,请点此查看更多更全内容