Uploaded by Aqib Khan

M.Aqib,fa20-bcs-037-, Os 2

advertisement
COMSATS University Islamabad
Attock Campus
Operating Systems Concepts
BSCS-V
Name:
MUHAMMAD AQIB KHAN
Registration No:
FA20-BCS-037
Assignment / Quiz #
Dated:
Assignment 2
27_October_2022
Submitted To
Mr. Muhammad Faseeh
Computer System:
It is an electronic machine, that executes instructions provided by the user through
input devices. There resembles an important component inside every computer system that is known as
CPU or Processor. This component executes instructions by performing athematic and logic operations
on it. There exists a clock inside computer system that keeps track of the CPU operations, on each tick of
the clock CPU performs one of the following operations Fetch, Decode, Execute and along with the
usage of these three Registers Program counter, Instruction registers, Accumulator with the
involvement of memory (Ram).
Combining all these in total we have Six (3) operations involved in the execution of the instruction but
not all of them are performed for every instruction. Before jumping into the working of all these steps let
me explain the components individually first.
Register:
It’s a type of memory very fast but very less compared to the other computer memories. It’s a
part of CPU.
Program Counter:
It keeps the address of the next instruction to be performed by the CPU. That address
represents a location in the memory (RAM).
Instruction Register:
Is a register that holds the instruction that is currently being executed. That
instruction is in machine language not understandable by human beings.
Accumulator Register:
It holds the result after the athematic or logic operations are performed on it.
Holds the data for a short time.
3 steps that are performed:
Let say user entered the instruction to increment a number by one every
time the loop executes. For which the code syntax is following:
Syntax:
Int result=0;
While(true){
result = result +1;
}
Initially everything looks like this…
1. Fetching:
The program counter is set to zero and the instruction is fetched at memory location
zero by CPU and then puts it into the instruction register.
2. Decoding:
Then the CPU decodes the instruction the first part of the instruction contain the
command while the other part contains the memory address.
The instruction is to load into the accumulator register the number which is at address 6.
3. Execute:
Now as the CPU knows what the instruction is about it will execute it and load the
number at address 6 into the accumulator register.
The number 1 is stored into accumulator as can be seen below.
Loop:
These three steps will be performed multiple times on instructions in the memory as the program
counter increments.
Program counter Increments:
As the program counter increments the CPU will fetch what is at the
address in program counter. Now the program counter will increment from 0 to 1.
Again Fetch:
The CPU will fetch the instruction from memory address taken from program counter
which is 1 and the instruction register will load that instruction.
Again Decode:
The CPU will decode the instruction which is to add what is at address 7 with
the value already there in the accumulator register.
Again Execute:
Now the CPU will execute the instruction and add 1 with the 1 that is already
there in the accumulator register. As the working of accumulator register has already been
described the result will be stored in the accumulator again
Program counter Increments:
The program counter will increment, and the value will be 2 now.
Again Fetch:
The CPU will fetch the instruction at address 2 from the memory and pass it to the
instruction register.
Again Decode:
The CPU will decode the instruction present in the instruction register which is
to store the current value in the accumulator at address 6.
Again Execute:
The CPU will execute the instruction now and it will store the number 2 onto the
address 6 in memory (RAM).
Conclusion:
The program counter will increment again and again, and the CPU will perform
these 3 operations repeatedly. Using the registers and the memory in some cases the operations
might not include all the of the registers. The completion of the 3 operations is called a Cycle. 1
complete cycle might look time consuming, but modern computers perform billions of
Cycles person second, and that’s how we can perform complex operations on it and even when I am
typing right now the same 3 operations are being performed thousand times, So that’s how computer
works.
Thank You
_____________________________________________________________________________________
Download