Language/Platform The project must be written in C, C++, or Java. If using C or C++,...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Language/Platform The project must be written in C, C++, or Java. If using C or C++, you must use a Unix fork to create processes and a Unix pipe for communication. If using Java, you must use the Runtime exec method to create processes and streams for communication. Your project will receive no credit if not using processes or if using threads instead of processes. All code must run successfully on our cs1.utdallas.edu server or csgrads1.utdallas.edu server. Any other method requires instructor approval. Problem Overview The project will simulate a simple computer system consisting of a CPU and Memory. The CPU and Memory will be simulated by separate processes that communicate. Memory will contain one program that the CPU will execute and then the simulation will end. Objectives 1) Learn how multiple processes can communicate and cooperate. 2) Understand low-level concepts important to an operating system. a. Processor interaction with main memory. b. Processor instruction behavior. c. Role of registers. d. Stack processing. e. Procedure calls. Problem Details f. System calls. g. Interrupt handling. h. Memory protection. I/O. 1. j. Virtualization/emulation CPU It will have these registers: PC, SP, IR, AC, X, Y. It will support the instructions shown on the next page of this document. It will run the user program at address 0. Instructions are fetched into the IR from memory. The operand can be fetched into a local variable. Each instruction should be executed before the next instruction is fetched. The user stack resides at the end of user memory and grows down toward address 0. The system stack resides at the end of system memory and grows down toward address 0. There is no hardware enforcement of stack size. The program ends when the End instruction is executed. The 2 processes should end at that time. The user program cannot access system memory (exits with error message). read(address) returns the value at the address write(address, data) - writes the data to the address Memory It will consist of 2000 integer entries, 0-999 for the user program, 1000-1999 for system code. It will support two operations: Memory will initialize itself by reading a program file. Note that the memory is simply storage; it has no real logic beyond reading and writing. Timer A timer will interrupt the processor after every X instructions, where X is a command-line parameter. Interrupt processing There are two forms of interrupts: the timer and a system call using the int instruction. In both cases the CPU should enter kernel mode. The stack pointer should be switched to the system stack. SP and PC registers should be saved on the system stack. (The handler may save additional registers). A timer interrupt should cause execution at address 1000. The int instruction should cause execution at address 1500. The iret instruction returns from an interrupt. Interrupts should be disabled during interrupt processing to avoid nested execution. To make it easy, do not allow interrupts during system calls or vice versa. Instruction set 1 = Load value 2 = Load addr 3 = LoadInd addr 4 = LoadIdxX addr 5 = LoadIdxY addr 6 = LoadSpX 7 = Store addr 8 = Get 9 = Put port 10 = AddX 11 = Addy 12 = SubX 13 = Suby 14 = CopyToX 15 = CopyFromX 16 = CopyToY 17 = CopyFrom Y 18 = CopyToSp 19 = CopyFromSp 20 = Jump addr 21 = JumpIfEqual addr 22 JumpIfNotEqual addr 23 = Call addr 24 = Ret 25 = IncX 26 = DecX 27 Push 28 = Pop 29 = Int 30 IRet 50 End = Load the value into the AC Load the value at the address into the AC Load the value from the address found in the given address into the AC (for example, if LoadInd 500, and 500 contains 100, then load from 100). Load the value at (address+X) into the AC (for example, if LoadIdxX 500, and X contains 10, then load from 510). Load the value at (address+Y) into the AC Load from (Sp+X) into the AC (if SP is 990, and X is 1, load from 991). Store the value in the AC into the address Gets a random int from 1 to 100 into the AC If port=1, writes AC as an int to the screen If port=2, writes AC as a char to the screen Add the value in X to the AC Add the value in Y to the AC Subtract the value in X from the AC Subtract the value in Y from the AC Copy the value in the AC to X Copy the value in X to the AC Copy the value in the AC to Y Copy the value in Y to the AC Copy the value in AC to the SP Copy the value in SP to the AC Jump to the address Jump to the address only if the value in the AC is zero Jump to the address only if the value in the AC is not zero Push return address onto stack, jump to the address Pop return address from the stack, jump to the address Increment the value in X Decrement the value in X Push AC onto stack Pop from stack into AC Perform system call Return from system call End execution Don't add to this list without approval Input File Format Each instruction is on a separate line, with its operand (if any) on the following line. The instruction or operand may be followed by a comment which the loader will ignore. Anything following an integer is a comment, whether or not it begins with //. A line may be blank in which case the loader will skip it without advancing the load address. A line may begin by a period followed by a number which causes the loader to change the load address. Your program should run correctly with the any valid input files. Sample Programs The input program filename and timer interrupt value should be command line arguments, for example: java Project1 program.txt 30 Here are two sample programs for illustration purposes: This program gets 3 random integers and sums them, then prints the result. Note that each line only has one number. 8 // Get 14 // CopyToX 8 // Get 16 // CopyToY 8 // Get 10 // AddX 11 // AddY 9 / Put 1 1 50 // End This program prints HI followed by a newline to the screen. To demonstrate a procedure call, the newline is printed by calling a procedure. 1 // Load 72=H 72 9 // Put 2 2 1 // Load 73=I 73 9 // Put 2 2 23 / Call 11 11 50 // End 1 // Load 10=newline 10 9 // Put 2 2 24 // Return Language/Platform The project must be written in C, C++, or Java. If using C or C++, you must use a Unix fork to create processes and a Unix pipe for communication. If using Java, you must use the Runtime exec method to create processes and streams for communication. Your project will receive no credit if not using processes or if using threads instead of processes. All code must run successfully on our cs 1.utdallas.edu server or csgrads1.utdallas.edu server. Any other method requires instructor approval. Problem Overview The project will simulate a simple computer system consisting of a CPU and Memory. The CPU and Memory will be simulated by separate processes that communicate. Memory will contain one program that the CPU will execute and then the simulation will end. Objectives 1) Learn how multiple processes can communicate and cooperate. 2) Understand low-level concepts important to an operating system. a. Processor interaction with main memory. b. Processor instruction behavior. c. Role of registers. d. Stack processing. e. Procedure calls. Problem Details f. System calls. g. Interrupt handling. h. Memory protection. I/O. 1. j. Virtualization/emulation CPU It will have these registers: PC, SP, IR, AC, X, Y. It will support the instructions shown on the next page of this document. It will run the user program at address 0. Instructions are fetched into the IR from memory. The operand can be fetched into a local variable. Each instruction should be executed before the next instruction is fetched. The user stack resides at the end of user memory and grows down toward address 0. The system stack resides at the end of system memory and grows down toward address 0. There is no hardware enforcement of stack size. The program ends when the End instruction is executed. The 2 processes should end at that time. The user program cannot access system memory (exits with error message). read(address) returns the value at the address write(address, data) - writes the data to the address Memory It will consist of 2000 integer entries, 0-999 for the user program, 1000-1999 for system code. It will support two operations: Memory will initialize itself by reading a program file. Note that the memory is simply storage; it has no real logic beyond reading and writing. Timer A timer will interrupt the processor after every X instructions, where X is a command-line parameter. Interrupt processing There are two forms of interrupts: the timer and a system call using the int instruction. In both cases the CPU should enter kernel mode. The stack pointer should be switched to the system stack. SP and PC registers should be saved on the system stack. (The handler may save additional registers). A timer interrupt should cause execution at address 1000. The int instruction should cause execution at address 1500. The iret instruction returns from an interrupt. Interrupts should be disabled during interrupt processing to avoid nested execution. To make it easy, do not allow interrupts during system calls or vice versa. Instruction set 1 = Load value 2 = Load addr 3 = LoadInd addr 4 = LoadIdxX addr 5 = LoadIdxY addr 6 = LoadSpX 7 = Store addr 8 = Get 9 = Put port 10 = AddX 11 = Addy 12 = SubX 13 = Suby 14 = CopyToX 15 = CopyFromX 16 = CopyToY 17 = CopyFrom Y 18 = CopyToSp 19 = CopyFromSp 20 = Jump addr 21 = JumpIfEqual addr 22 = JumpIfNotEqual addr 23 = Call addr 24 = Ret 25 = IncX 26 = DecX 27 Push 28 = Pop 29 = Int 30 IRet 50 End = Load the value into the AC Load the value at the address into the AC Load the value from the address found in the given address into the AC (for example, if LoadInd 500, and 500 contains 100, then load from 100). Load the value at (address+X) into the AC (for example, if LoadIdxX 500, and X contains 10, then load from 510). Load the value at (address+Y) into the AC Load from (Sp+X) into the AC (if SP is 990, and X is 1, load from 991). Store the value in the AC into the address Gets a random int from 1 to 100 into the AC If port=1, writes AC as an int to the screen If port=2, writes AC as a char to the screen Add the value in X to the AC Add the value in Y to the AC Subtract the value in X from the AC Subtract the value in Y from the AC Copy the value in the AC to X Copy the value in X to the AC Copy the value in the AC to Y Copy the value in Y to the AC Copy the value in AC to the SP Copy the value in SP to the AC Jump to the address Jump to the address only if the value in the AC is zero Jump to the address only if the value in the AC is not zero Push return address onto stack, jump to the address Pop return address from the stack, jump to the address Increment the value in X Decrement the value in X Push AC onto stack Pop from stack into AC Perform system call Return from system call End execution Don't add to this list without approval Input File Format Each instruction is on a separate line, with its operand (if any) on the following line. The instruction or operand may be followed by a comment which the loader will ignore. Anything following an integer is a comment, whether or not it begins with //. A line may be blank in which case the loader will skip it without advancing the load address. A line may begin by a period followed by a number which causes the loader to change the load address. Your program should run correctly with the any valid input files. Sample Programs The input program filename and timer interrupt value should be command line arguments, for example: java Project1 program.txt 30 Here are two sample programs for illustration purposes: This program gets 3 random integers and sums them, then prints the result. Note that each line only has one number. 8 // Get 14 // CopyToX 8 // Get 16 // CopyToY 8 // Get 10 // AddX 11 // Addy 9 / Put 1 1 50 // End This program prints HI followed by a newline to the screen. To demonstrate a procedure call, the newline is printed by calling a procedure. 1 // Load 72=H 72 9 // Put 2 2 1 // Load 73=I 73 9 // Put 2 2 23 / Call 11 11 50 // End 1 // Load 10=newline 10 9 // Put 2 2 24 // Return Language/Platform The project must be written in C, C++, or Java. If using C or C++, you must use a Unix fork to create processes and a Unix pipe for communication. If using Java, you must use the Runtime exec method to create processes and streams for communication. Your project will receive no credit if not using processes or if using threads instead of processes. All code must run successfully on our cs1.utdallas.edu server or csgrads1.utdallas.edu server. Any other method requires instructor approval. Problem Overview The project will simulate a simple computer system consisting of a CPU and Memory. The CPU and Memory will be simulated by separate processes that communicate. Memory will contain one program that the CPU will execute and then the simulation will end. Objectives 1) Learn how multiple processes can communicate and cooperate. 2) Understand low-level concepts important to an operating system. a. Processor interaction with main memory. b. Processor instruction behavior. c. Role of registers. d. Stack processing. e. Procedure calls. Problem Details f. System calls. g. Interrupt handling. h. Memory protection. I/O. 1. j. Virtualization/emulation CPU It will have these registers: PC, SP, IR, AC, X, Y. It will support the instructions shown on the next page of this document. It will run the user program at address 0. Instructions are fetched into the IR from memory. The operand can be fetched into a local variable. Each instruction should be executed before the next instruction is fetched. The user stack resides at the end of user memory and grows down toward address 0. The system stack resides at the end of system memory and grows down toward address 0. There is no hardware enforcement of stack size. The program ends when the End instruction is executed. The 2 processes should end at that time. The user program cannot access system memory (exits with error message). read(address) returns the value at the address write(address, data) - writes the data to the address Memory It will consist of 2000 integer entries, 0-999 for the user program, 1000-1999 for system code. It will support two operations: Memory will initialize itself by reading a program file. Note that the memory is simply storage; it has no real logic beyond reading and writing. Timer A timer will interrupt the processor after every X instructions, where X is a command-line parameter. Interrupt processing There are two forms of interrupts: the timer and a system call using the int instruction. In both cases the CPU should enter kernel mode. The stack pointer should be switched to the system stack. SP and PC registers should be saved on the system stack. (The handler may save additional registers). A timer interrupt should cause execution at address 1000. The int instruction should cause execution at address 1500. The iret instruction returns from an interrupt. Interrupts should be disabled during interrupt processing to avoid nested execution. To make it easy, do not allow interrupts during system calls or vice versa. Instruction set 1 = Load value 2 = Load addr 3 = LoadInd addr 4 = LoadIdxX addr 5 = LoadIdxY addr 6 = LoadSpX 7 = Store addr 8 = Get 9 = Put port 10 = AddX 11 = Addy 12 = SubX 13 = Suby 14 = CopyToX 15 = CopyFromX 16 = CopyToY 17 = CopyFrom Y 18 = CopyToSp 19 = CopyFromSp 20 = Jump addr 21 = JumpIfEqual addr 22 JumpIfNotEqual addr 23 = Call addr 24 = Ret 25 = IncX 26 = DecX 27 Push 28 = Pop 29 = Int 30 IRet 50 End = Load the value into the AC Load the value at the address into the AC Load the value from the address found in the given address into the AC (for example, if LoadInd 500, and 500 contains 100, then load from 100). Load the value at (address+X) into the AC (for example, if LoadIdxX 500, and X contains 10, then load from 510). Load the value at (address+Y) into the AC Load from (Sp+X) into the AC (if SP is 990, and X is 1, load from 991). Store the value in the AC into the address Gets a random int from 1 to 100 into the AC If port=1, writes AC as an int to the screen If port=2, writes AC as a char to the screen Add the value in X to the AC Add the value in Y to the AC Subtract the value in X from the AC Subtract the value in Y from the AC Copy the value in the AC to X Copy the value in X to the AC Copy the value in the AC to Y Copy the value in Y to the AC Copy the value in AC to the SP Copy the value in SP to the AC Jump to the address Jump to the address only if the value in the AC is zero Jump to the address only if the value in the AC is not zero Push return address onto stack, jump to the address Pop return address from the stack, jump to the address Increment the value in X Decrement the value in X Push AC onto stack Pop from stack into AC Perform system call Return from system call End execution Don't add to this list without approval Input File Format Each instruction is on a separate line, with its operand (if any) on the following line. The instruction or operand may be followed by a comment which the loader will ignore. Anything following an integer is a comment, whether or not it begins with //. A line may be blank in which case the loader will skip it without advancing the load address. A line may begin by a period followed by a number which causes the loader to change the load address. Your program should run correctly with the any valid input files. Sample Programs The input program filename and timer interrupt value should be command line arguments, for example: java Project1 program.txt 30 Here are two sample programs for illustration purposes: This program gets 3 random integers and sums them, then prints the result. Note that each line only has one number. 8 // Get 14 // CopyToX 8 // Get 16 // CopyToY 8 // Get 10 // AddX 11 // AddY 9 / Put 1 1 50 // End This program prints HI followed by a newline to the screen. To demonstrate a procedure call, the newline is printed by calling a procedure. 1 // Load 72=H 72 9 // Put 2 2 1 // Load 73=I 73 9 // Put 2 2 23 / Call 11 11 50 // End 1 // Load 10=newline 10 9 // Put 2 2 24 // Return Language/Platform The project must be written in C, C++, or Java. If using C or C++, you must use a Unix fork to create processes and a Unix pipe for communication. If using Java, you must use the Runtime exec method to create processes and streams for communication. Your project will receive no credit if not using processes or if using threads instead of processes. All code must run successfully on our cs 1.utdallas.edu server or csgrads1.utdallas.edu server. Any other method requires instructor approval. Problem Overview The project will simulate a simple computer system consisting of a CPU and Memory. The CPU and Memory will be simulated by separate processes that communicate. Memory will contain one program that the CPU will execute and then the simulation will end. Objectives 1) Learn how multiple processes can communicate and cooperate. 2) Understand low-level concepts important to an operating system. a. Processor interaction with main memory. b. Processor instruction behavior. c. Role of registers. d. Stack processing. e. Procedure calls. Problem Details f. System calls. g. Interrupt handling. h. Memory protection. I/O. 1. j. Virtualization/emulation CPU It will have these registers: PC, SP, IR, AC, X, Y. It will support the instructions shown on the next page of this document. It will run the user program at address 0. Instructions are fetched into the IR from memory. The operand can be fetched into a local variable. Each instruction should be executed before the next instruction is fetched. The user stack resides at the end of user memory and grows down toward address 0. The system stack resides at the end of system memory and grows down toward address 0. There is no hardware enforcement of stack size. The program ends when the End instruction is executed. The 2 processes should end at that time. The user program cannot access system memory (exits with error message). read(address) returns the value at the address write(address, data) - writes the data to the address Memory It will consist of 2000 integer entries, 0-999 for the user program, 1000-1999 for system code. It will support two operations: Memory will initialize itself by reading a program file. Note that the memory is simply storage; it has no real logic beyond reading and writing. Timer A timer will interrupt the processor after every X instructions, where X is a command-line parameter. Interrupt processing There are two forms of interrupts: the timer and a system call using the int instruction. In both cases the CPU should enter kernel mode. The stack pointer should be switched to the system stack. SP and PC registers should be saved on the system stack. (The handler may save additional registers). A timer interrupt should cause execution at address 1000. The int instruction should cause execution at address 1500. The iret instruction returns from an interrupt. Interrupts should be disabled during interrupt processing to avoid nested execution. To make it easy, do not allow interrupts during system calls or vice versa. Instruction set 1 = Load value 2 = Load addr 3 = LoadInd addr 4 = LoadIdxX addr 5 = LoadIdxY addr 6 = LoadSpX 7 = Store addr 8 = Get 9 = Put port 10 = AddX 11 = Addy 12 = SubX 13 = Suby 14 = CopyToX 15 = CopyFromX 16 = CopyToY 17 = CopyFrom Y 18 = CopyToSp 19 = CopyFromSp 20 = Jump addr 21 = JumpIfEqual addr 22 = JumpIfNotEqual addr 23 = Call addr 24 = Ret 25 = IncX 26 = DecX 27 Push 28 = Pop 29 = Int 30 IRet 50 End = Load the value into the AC Load the value at the address into the AC Load the value from the address found in the given address into the AC (for example, if LoadInd 500, and 500 contains 100, then load from 100). Load the value at (address+X) into the AC (for example, if LoadIdxX 500, and X contains 10, then load from 510). Load the value at (address+Y) into the AC Load from (Sp+X) into the AC (if SP is 990, and X is 1, load from 991). Store the value in the AC into the address Gets a random int from 1 to 100 into the AC If port=1, writes AC as an int to the screen If port=2, writes AC as a char to the screen Add the value in X to the AC Add the value in Y to the AC Subtract the value in X from the AC Subtract the value in Y from the AC Copy the value in the AC to X Copy the value in X to the AC Copy the value in the AC to Y Copy the value in Y to the AC Copy the value in AC to the SP Copy the value in SP to the AC Jump to the address Jump to the address only if the value in the AC is zero Jump to the address only if the value in the AC is not zero Push return address onto stack, jump to the address Pop return address from the stack, jump to the address Increment the value in X Decrement the value in X Push AC onto stack Pop from stack into AC Perform system call Return from system call End execution Don't add to this list without approval Input File Format Each instruction is on a separate line, with its operand (if any) on the following line. The instruction or operand may be followed by a comment which the loader will ignore. Anything following an integer is a comment, whether or not it begins with //. A line may be blank in which case the loader will skip it without advancing the load address. A line may begin by a period followed by a number which causes the loader to change the load address. Your program should run correctly with the any valid input files. Sample Programs The input program filename and timer interrupt value should be command line arguments, for example: java Project1 program.txt 30 Here are two sample programs for illustration purposes: This program gets 3 random integers and sums them, then prints the result. Note that each line only has one number. 8 // Get 14 // CopyToX 8 // Get 16 // CopyToY 8 // Get 10 // AddX 11 // Addy 9 / Put 1 1 50 // End This program prints HI followed by a newline to the screen. To demonstrate a procedure call, the newline is printed by calling a procedure. 1 // Load 72=H 72 9 // Put 2 2 1 // Load 73=I 73 9 // Put 2 2 23 / Call 11 11 50 // End 1 // Load 10=newline 10 9 // Put 2 2 24 // Return
Expert Answer:
Answer rating: 100% (QA)
Cpujava import javaio import javautilRandom import javautilScanner public class CPU Declare required registers static int PC 0 SP 1000 IR AC X Y timerFlag numofinstructions 0 static int systemStacktop ... View the full answer
Related Book For
Business Law Text and Cases
ISBN: 978-0324655223
11th Edition
Authors: Kenneth W. Clarkson, Roger LeRoy Miller, Gaylord A. Jentz, F
Posted Date:
Students also viewed these programming questions
-
If a CPU issues one memory request every instruction and the computer runs at 200 MIPS, about how many CPUs will it take to saturate a 400-MHz bus? Assume that a memory reference requires one bus...
-
A processor accesses main memory with an average access time of T2. A smaller cache memory is interposed between the processor and main memory. The cache has a significantly faster access time of T1...
-
The UNIX kernel will dynamically grow a processs stack in virtual memory as needed, but it will never try to shrink it. Consider the case in which a program calls a C subroutine that allocates a...
-
After reviewing the definition of Behavior Leadership Theory, explain what effect behavioral leadership theory has on traditional police in their role as a chief or any other leadership role in law...
-
Consider a project with the following cash flows: a. How many internal rates of return does this project have? b. Which of the following numbers is the project IRR: (i) -50%; (ii) -12%; (iii) -5%;...
-
How could Amazon eliminate concerns with employees using the tool to sabotage other employees?
-
Indicate by letters which of the following control activities match with the following descriptions: Separation of duties (SD) Restricted access (RA) Proper authorization (PA) Adequate documents and...
-
What are the assumptions underlying common queuing models?
-
The analyzing of organizations in the lens of this theory features the use of asking questions in order to gage the health of the organization. One of the questions often asked with the use of this...
-
Pulsar Optics produces medical lasers for use in hospitals. The accounts and their balances appear in the ledger of Pulsar Optics on April 30 of the current year as follows: Preferred 1% Stock, $120...
-
What strategies are most effective in optimizing organizational skills within high-complexity environments, and how do these strategies affect overall productivity and efficiency ?
-
What factors would cause you to initiate follow-up contacts with one or more group members after group termination? What would be the purpose of such contacts?
-
Assignment With a partner or alone, create a portfolio of eight different printed advertisements. You may use magazines, phone books, or newspapers. Look for an array of different ads targeting...
-
What factors contributed to Davids elevated plasma K + concentration (hyperkalemia)? Was his K + balance positive, negative, or normal? How did the initial treatment with insulin and saline help to...
-
What were they key underlying factors that led to the financial conditions immediately prior to the European debt crisis? Describe what market failures, if any, contributed to these conditions....
-
Project Selection for final project: Assignment 1 (5 points): Submit in a Word Document 1. Select a project that you worked on in the past (this is the title of your Assignment 1 paper). This could...
-
What is the algorithmic strategy of divide and conquer?
-
The diagram shows the two forces acting on a small object. Which of the following is the resultant force on the object? A. 8 N downwards B. 8 N upwards C. 2 N downwards D. 2 N upwards 3 N 5 N
-
In 1994, Gary Kremen registered the domain name sex.com with Network Solutions, Inc., to the name of Kremens business, Online Classifieds. Later, Stephen Cohen sent Network Solutions a letter that he...
-
What if Johns neighbor made his promise to help reassemble the garage at the time he and John were moving it to Johns property, saying, Since you helped me take it down, I will help you put it back...
-
Stewart Lamle invented Farook, a board game similar to Tic Tac Toe. In May 1996, Lamle began negotiating with Mattel, Inc., to license Farook for distribution outside the United States. On June 11,...
-
Recording effects of transactions in T-accounts Record the transactions below for Amena Company by recording debit and credit amounts directly in the following T-accounts: Cash; Accounts Receivable;...
-
Identifying type and normal balances of accounts For each of the following (1) identify the type of account as an asset, liability, equity, revenue, or expense, (2) enter debit (Dr.) or credit (Cr.)...
-
Preparing a trial balance After recording the transactions of Exercise 3-2 in T-accounts and calculating the ending balance of each account, prepare a trial balance. Use May 31, 2008, as its report...
Study smarter with the SolutionInn App