Presentation is loading. Please wait.

Presentation is loading. Please wait.

Georgia Institute of Technology Student Computer Simulation Barbara Ericson Georgia Tech Sept 2005.

Similar presentations


Presentation on theme: "Georgia Institute of Technology Student Computer Simulation Barbara Ericson Georgia Tech Sept 2005."— Presentation transcript:

1 Georgia Institute of Technology Student Computer Simulation Barbara Ericson Georgia Tech Sept 2005

2 Georgia Institute of Technology Operating System - Organizer Keep track of executing programs –Give them time with the CPU –A program gets a slice of time with the CPU Keep track of memory –Decide when to move some data to disk (virtual memory) Keep track of disk space –Decide where to store stuff Interface with the user –Accept input via keyboard and mouse Keep track of devices –USB drives, cameras, etc

3 Georgia Institute of Technology Try it Out Type ctrl-alt-delete (press all keys at the same time) –To bring up the task manager –Click on each of the tabs To see the applications running To see the processes that are running To see how much memory is used

4 Georgia Institute of Technology CPU – Calculator Plus More Add, subtract, multiply, divide numbers Compare numbers –Characters are encoded as numbers Jump to a new instruction based on the result of a comparison Can only work with one program at a time! –Keeps a program counter which is the address of the currently executing instruction

5 Georgia Institute of Technology Memory – Whiteboard Holds the currently executing programs and their data Clears when the power is turned off Much faster than disk Has addresses for data based on bytes Can get data from an address Can put data into an address

6 Georgia Institute of Technology Disk – Storage Facility Stores data and programs Doesn’t clear when the power is turned off Much slower than memory Much cheaper than memory

7 Georgia Institute of Technology Program - Recipe Set of instructions to the computer Carried out by the CPU Accomplishes some task

8 Georgia Institute of Technology Computer Startup The power is turned on –The Basic Input/Output System (BIOS) Loads from a memory chip (ROM) and executes Initializes the hardware (keyboard, disk drive, mouse, etc) –Then loads and executes the operating system The Operating System waits for user input The user starts a program –By double clicking on an icon or file –Or by click on Start->Program->Some Program

9 Georgia Institute of Technology Program Execution The operating system creates a process for the program and reads it into memory It gives it a time slice of the CPU It saves the current state of the CPU when it gives another program a time slice of the CPU –Context switch It can restore the state of the CPU

10 Georgia Institute of Technology Student Computer Simulation –Operating System – need 1 Keep a list of programs to be run Tell CPU to run a program (set program counter to memory address) Tell CPU to switch to another program –Central Processing Unit – need 1 Keep track of the contents of Registers A, B, and C and the program counter Be able to save current state to memory –Memory – need 1 Have a list of values for addresses (on board) –Disk – need 1 Hold original programs and byte code versions

11 Georgia Institute of Technology Simulation Give the person playing the disk the two programs and the assembler version of the programs Have the operating system ask for program 1 to be loaded into memory at address 0 Have the disk give a copy of the assembler version of program 1 to the memory –And assign an address to the start of it (0) Have the operating system tell the CPU to start executing from the memory address of the first program –Have the CPU update the program counter to 0 –Ask the memory for the instruction at this address –Execute the instruction and increment the program counter

12 Georgia Institute of Technology Simulation – page 2 Have the operating system ask for program 2 to be loaded into memory at address 64 Have the disk give a copy of program 2 to the memory –And assign an address to the start of it (64) Have the operating system tell the CPU to save the current state to the memory Ask memory to save the values of the registers and program counter to 200 Have the operating system tell the CPU to start executing from the memory address of the second program (64) –Have the CPU update the program counter to 64 –Ask the memory for the instruction at this address –Execute the first two instructions and increment the program counter Keep doing this till both programs have finished –When a program finishes tell the CPU and it can remove the program from the list of programs to run

13 Georgia Institute of Technology Program 1 // how many pizza slices? int numPeople = 30; int numSlicesPerPerson = 2; int totalSlices = numPeople * numSlicesPerPerson; int numPizzas = totalSlices / 10;

14 Georgia Institute of Technology Compiling Computers can’t execute source code –They need to execute bytecodes Instructions for the machine the code is running on –1 might be add A and B and store the result in C We compile Java source code Name.java into Name.class –bytecodes for a virtual machine Not any particular machine Then we execute Java class files –Runs a Java Virtual Machine to interpret the bytecodes –Or compile to native bytecodes using a just-in-time compiler

15 Georgia Institute of Technology Assembler Low level programming language –Names for instructions instead of numbers ADD instead of 1 LOADA instead of 20 Use an assembler to convert to the bytecodes for a machine

16 Georgia Institute of Technology Example Assembler LOADA mem - Load register A from memory address LOADB mem - Load register B from memory address CONB con - Load a constant value into register B SAVEB mem - Save register B to memory address SAVEC mem - Save register C to memory address ADD - Add A and B and store the result in C SUB - Subtract A and B and store the result in C MUL - Multiply A and B and store the result in C DIV - Divide A and B and store the result in C COM - Compare A and B and store the result in test JUMP addr - Jump to an address JEQ addr - Jump, if equal, to address JNEQ addr - Jump, if not equal, to address JG addr - Jump, if greater than, to address JGE addr - Jump, if greater than or equal, to address JL addr - Jump, if less than, to address JLE addr - Jump, if less than or equal, to address STOP - Stop execution

17 Georgia Institute of Technology Program 1 Assembler 0 CONB 30 // put 30 in register B 1 SAVEB 128 // int numPeople = 30; 2 CONB 2 // put 2 in register B 3 SAVEB 132 // int numSlicesPerPerson = 2; 4 LOADA 128 // get value in address 128 5 MUL // multiply a and b and store result in c 6 SAVEC 136 // int totalSlices = numPeople * numSlicesPerPerson; 7 LOADA 136 8 CONB 10 9 DIV // divide a and b and store result in c 10 SAVEC 140 int numPizzas = totalSlices / 10; 11 STOP

18 Georgia Institute of Technology Program 2 // calculate if we have enough material int width = 30; int length = 50; int total = width * height;

19 Georgia Institute of Technology Program 2 Assembler 0 CONB 30 1 SAVEB 160 // (int width = 30) 2 CONB 50 3 SAVEB 164 // (int height = 50) 4 LOADA 160 // load width 5 LOADB 164 // load height 6 MUL 7 SAVEC 168 // (int total = width * height) 8 STOP


Download ppt "Georgia Institute of Technology Student Computer Simulation Barbara Ericson Georgia Tech Sept 2005."

Similar presentations


Ads by Google