Advertisement
Guest User

Untitled

a guest
Jan 30th, 2015
224
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.54 KB | None | 0 0
  1. II. Project Description
  2.  
  3. Language/Platform
  4.  
  5. The project must be written in C, C++, or Java.
  6. If using C or C++, you must use a Unix fork to create processes and a Unix pipe for communication.
  7. If using Java, you must use the Runtime exec method to create processes and streams for communication.
  8. Your project will receive no credit if not using processes or if using threads instead of processes.
  9. All code must run successfully on our cs1.utdallas.edu server.
  10. Any other method requires instructor approval.
  11.  
  12.  
  13. Problem Overview
  14.  
  15. The project will simulate a simple computer system consisting of a CPU and Memory.
  16. The CPU and Memory will be simulated by separate processes that communicate.
  17.  
  18.  
  19. Objectives
  20.  
  21. 1) Learn how multiple processes can communicate and cooperate.
  22. 2) Understand low-level concepts important to an operating system.
  23. a. Processor interaction with main memory.
  24. b. Processor instruction behavior.
  25. c. Role of registers.
  26. d. Stack processing.
  27. e. Procedure calls. f. System calls.
  28. g. Interrupt handling.
  29. h. Memory protection.
  30. i. I/O.
  31.  
  32.  
  33. Problem Details
  34.  
  35. CPU
  36. It will have these registers: PC, SP, IR, AC, X, Y.
  37. It will support the instructions shown on the next page of this document.
  38. It will run the user program at address 0.
  39. Instructions are fetched into the IR from memory. The operand can be fetched into a local variable.
  40. Each instruction should be executed before the next instruction is fetched.
  41. The user stack resides at the end of user memory and grows down toward address 0.
  42. The system stack resides at the end of system memory and grows down toward address 0.
  43. There is no hardware enforcement of stack size.
  44. The program ends when the End instruction is executed. The 2 processes should end at that time.
  45. The user program cannot access system memory (exits with error message).
  46.  
  47. Memory
  48. It will consist of 2000 integer entries, 0-999 for the user program, 1000-1999 for system code.
  49. It will support two operations:
  50. read(address) - returns the value at the address
  51. write(address, data) - writes the data to the address
  52. Memory will initialize itself by reading a program file.
  53.  
  54. Timer
  55. A timer will interrupt the processor after every X instructions, where X is a command-line parameter.
  56.  
  57. Interrupt processing
  58. There are two forms of interrupts: the timer and a system call using the int instruction.
  59. The stack is switched to the system stack.
  60. Registers should be saved on the system stack.
  61. A timer interrupt should cause execution at address 1000.
  62. The int instruction should cause execution at address 1500.
  63. Interrupts should be disabled during interrupt processing to avoid nested execution.
  64. The iret instruction returns from an interrupt.
  65.  
  66.  
  67. Instruction set
  68.  
  69. 1 = Load value
  70. 2 = Load addr
  71. 3 = LoadInd addr
  72. 4 = LoadIdxX addr
  73. 5 = LoadIdxY addr
  74. 6 = LoadSpX
  75. 7 = Store addr
  76. 8 = Get
  77. 9 = Put port
  78.  
  79. 10 = AddX
  80. 11 = AddY
  81. 12 = SubX
  82. 13 = SubY
  83. 14 = CopyToX
  84. 15 = CopyFromX
  85. 16 = CopyToY
  86. 17 = CopyFromY
  87. 18 = CopyToSp
  88. 19 = CopyFromSp
  89. 20 = Jump addr
  90. 21 = JumpIfEqual addr
  91. 22 = JumpIfNotEqual addr
  92. 23 = Call addr
  93. 24 = Ret
  94. 25 = IncX
  95. 26 = DecX
  96. 27 = Push
  97. 28 = Pop
  98. 29 = Int
  99. 30 = IRet
  100. 50 = End Load the value into the AC
  101. Load the value at the address into the AC
  102. Load the value from the address found in the address into the AC
  103. Load the value at (address+X) into the AC
  104. Load the value at (address+Y) into the AC
  105. Load from (Sp+X) into the AC
  106. Store the value in the AC into the address
  107. Gets a random int from 1 to 100 into the AC
  108. If port=1, writes AC as an int to the screen
  109. If port=2, writes AC as a char to the screen
  110. Add the value in X to the AC
  111. Add the value in Y to the AC
  112. Subtract the value in X from the AC
  113. Subtract the value in Y from the AC
  114. Copy the value in the AC to X
  115. Copy the value in X to the AC
  116. Copy the value in the AC to Y
  117. Copy the value in Y to the AC
  118. Copy the value in AC to the SP
  119. Copy the value in SP to the AC
  120. Jump to the address
  121. Jump to the address only if the value in the AC is zero
  122. Jump to the address only if the value in the AC is not zero
  123. Push return address onto stack, jump to the address
  124. Pop return address from the stack, jump to the address
  125. Increment the value in X
  126. Decrement the value in X
  127. Push AC onto stack
  128. Pop from stack into AC
  129. Set system mode, switch stack, push SP and PC, set new SP and PC
  130. Restore registers, set user mode
  131. End execution
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement