B. Number of Records in Page Table Number of Virtual Pages 4GB/32KB 128K. C. Physical Memory Size 32KB 32K 1GB
B. Number of Records in Page Table Number of Virtual Pages 4GB/32KB 128K. C. Physical Memory Size 32KB 32K 1GB
A binary
instruction code is stored in one word of memory. The instruction has four
parts: an indirect bit, an operation code, a register code part to specify one
of 64 registers, and an address part. a) How many bits are there in the
operation code, the register code part, and the address part? b) Draw the
instruction word format and indicate the number of bits in each part. c) How
many bits are there in the data and address inputs of the memory?
Problem 5: Consider a processor that uses a 32-bit virtual memory address. The
memory consists of 32-bit words and is byte addressable. Determine,
b. If the page size is 32KB, then how many records should the page table hold?
c. How much data space should physical memory have to hold 32K pages? d. How
many bits of storage will be needed in a record of TLB? Answer:
d. A TLB record contains 1 valid bit, 1 dirty bit, 1 reference bit, page table index
requiring log2(128K), or 17 bits, and physical page number requiring log2(32K), or 15
bits. Therefore, a TLB record should hold 1 + 1 + 1 + 17 + 15 = 35 bits.
Consider a memory hierarchy with a write back cache. The cache has an access
time of 20nS. Ninety (90%) of all the memory access are found in the cache
itself. The main memory access time is 300nS. The 20% of the cache blocks
are dirty. The cache block size is 4 bytes. Calculate the average memory
access time.
https://gateoverflow.in/14480/formula-write-back-write-through-access-time-
parallel-serial?show=14502#a14502
https://stackoverflow.com/questions/48277970/write-back-cache-formula-
with-write-allocate-policy
If we consider an hierarchical single level write back cache with write allocate policy,
then the formula for average access time during write operation is given by :-
Twrite = (H)(Tc) + (1-H)(Tc + Tm + (x*Tm)).
Twrite = (Tc * H) + (1-H)(Tc + (x * Tm))
Where,
H= hit ratio of cache.
Tc=access time of cache.
Tm= access time of memory.
x= fraction of cache blocks which are dirty
- Example Instruction Format: `OP R1, #value` (where `OP` is the arithmetic
operation, and `value` is the immediate operand)
- Example: `ADD R1, #10` (Add the immediate value 10 to the content of register
R1)
- Example Instruction Format: `OP R1, R2` (where `OP` is the arithmetic operation,
and R1 and R2 are registers)
- Example: `ADD R1, R2` (Add the content of register R2 to the content of register
R1)
- Example: `ADD R1, 500` (Add the content of memory location 500 to the content
of register R1)
- In this mode, the operand is specified by adding an index value to a base address.
- Example Instruction Format: `OP R1, base_register + index` (where `OP` is the
arithmetic operation, `base_register` is a register holding the base address, and
`index` is an offset)
- Example: `ADD R1, R2 + 10` (Add the content of memory location stored at the
address obtained by adding 10 to the content of register R2 to the content of register
R1)
- In this mode, the operand is specified indirectly through a memory address stored
in a register or memory location.
- Example Instruction Format: `OP R1, (R2)` (where `OP` is the arithmetic operation,
and `R2` contains the memory address of the operand)
- Example: `ADD R1, (R2)` (Add the content of memory location pointed to by the
content of register R2 to the content of register R1)
https://www.scribd.com/document/109702768/Assignment-2-CSD
https://www.studocu.com/in/document/dr-apj-abdul-kalam-technical-university/
computer-science/assignment-2-solutions/10370678?origin=organic-success-
document-viewer-cta
Three-address instructions: ``` LOAD R1, A LOAD R2, B SUB R1, R1, R2 LOAD R3,
C LOAD R4, D LOAD R5, E MUL R4, R4, R5 LOAD R6, F SUB R4, R4, R6 MUL R3,
R3, R4 ADD R1, R1, R3 LOAD R7, H LOAD R8, K MUL R7, R7, R8 ADD R1, R1, R7
STORE X, R1
# Initialize values
# OP R1, R2 => R1 = R1 OP R2
# Initialize values
ADD R1, 2 # R1 = R1 + 2 (3 + 2)
SUB R2, 4 # R2 = R2 - 4 (5 - 4)
Miss: A miss happens when the data or instruction requested by the CPU is not
found in the cache memory. As a result, the processor must fetch the required
information from the slower main memory.
Hit Ratio: The hit ratio is the ratio of cache hits to the total number of memory
access attempts. It is typically expressed as a percentage and gives an
indication of how effectively the cache is being utilized. A higher hit ratio
indicates that a larger portion of memory accesses are being served from the
cache rather than main memory.
Cache coherence refers to the consistency of data stored in multiple caches that are
connected to a shared memory system. In a multiprocessor or multicore system
where each processor or core has its own cache memory, cache coherence ensures
that all caches have a consistent view of memory.
When multiple processors or cores share access to the same memory locations,
cache coherence ensures that any updates made by one processor or core are
visible to all other processors or cores. This prevents data inconsistency issues that
could arise if one processor reads stale data from its cache while another processor
has updated the same data in its cache.
These are some of the common addressing modes used in computer architectures.
Each addressing mode offers different ways to specify operands in machine
instructions, providing flexibility and efficiency in programming and execution.
https://www.gatevidyalay.com/addressing-modes/
CPU registers are small, high-speed storage locations within the CPU (Central
Processing Unit) that hold data temporarily during processing. Each register serves a
specific purpose in the execution of instructions and the management of data within
the CPU. Here are some common CPU registers and their functions:
- The Program Counter holds the memory address of the next instruction to be fetched and
executed.
- It increments automatically after fetching each instruction, pointing to the next instruction
in memory.
2. **Instruction Register (IR):**
- The Memory Address Register holds the memory address of data to be accessed or
modified in main memory.
- The Memory Data Register holds the data read from or to be written into main memory.
- It acts as an interface between the CPU and main memory, facilitating data transfer.
5. **Accumulator (ACC):**
- The Accumulator is a general-purpose register used for arithmetic and logic operations.
- It stores intermediate results and final results of arithmetic and logic operations.
- They hold an offset value that is added to a base address to calculate the effective
memory address for data access.
- The Status Register holds condition flags that reflect the outcome of arithmetic and logic
operations.
- Common flags include zero flag (Z), carry flag (C), overflow flag (V), and sign flag (S),
among others.
8. **Stack Pointer (SP):**
- The Stack Pointer holds the memory address of the top of the stack in memory.
- It is used for managing the stack data structure, especially during subroutine calls and
returns.
- The Program Status Word is a special register that contains various control and status
bits.
- It includes bits for interrupt enable/disable, privilege levels, and processor mode.
These are some of the common CPU registers found in most computer architectures. They
play crucial roles in instruction execution, data manipulation, and control flow within the
CPU.
Explain thr following: Main memory, Secondary memory and cache memory
- Main memory refers to the primary storage space directly accessible by the CPU.
- It is volatile, meaning it loses its contents when the power is turned off.
- Main memory is used to store data and instructions that are actively being used by the
CPU during program execution.
- It provides fast access to data but has limited capacity compared to secondary memory.
- Common types of main memory include DRAM (Dynamic RAM) and SRAM (Static RAM).
- Secondary memory refers to storage devices that hold data and programs for long-term
storage.
- Examples include hard disk drives (HDDs), solid-state drives (SSDs), optical disks (CDs,
DVDs), and magnetic tapes.
- Secondary memory is non-volatile, meaning it retains its contents even when the power
is turned off.
- It has larger capacity and slower access times compared to main memory.
- Secondary memory is used for storing data and programs that are not actively being
used by the CPU, such as files and applications.
3. **Cache Memory:**
- Cache memory is a small, high-speed memory located between the CPU and main
memory.
- Its purpose is to store frequently accessed data and instructions to reduce the average
time taken to access memory.
- It exploits the principle of locality, where recently accessed data is likely to be accessed
again in the near future.
- There are different levels of cache (L1, L2, L3) with varying sizes and speeds, with L1
cache being the closest to the CPU and typically the fastest.
- Cache memory is managed by hardware and often uses cache coherence protocols to
ensure data consistency in multi-core or multi-processor systems.
In summary, main memory is the primary storage space used by the CPU during program
execution, secondary memory provides long-term storage for data and programs, and cache
memory is a small, high-speed memory used to reduce memory access times by storing
frequently accessed data and instructions. Each type of memory serves a specific purpose in
computer systems, balancing speed, capacity, and cost.
https://tutorialspoint.com/race-condition-critical-section-and-semaphore
Mutual Exclusion
Mutual exclusion implies that only one process can be inside the critical
section at any time. If any other processes require the critical section,
they must wait until it is free.
Progresss
Progress means that if a process is not using the critical section, then it
should not stop any other process from accessing it. In other words,
any process can enter a critical section if it is free.
Bounded Waitings
Bounded waiting means that each process must have a limited waiting
time. Itt should not wait endlessly to access the critical section.
A semaphore uses two atomic operations, wait and signal for process
synchronization.
wait(S){
while (S<=0);
S--;
}
The signal operation increments the value of its argument S.
signal(S){
S++;
Ensure you state any problems with the methods you describe.
https://www.cs.fsu.edu/~hawkes/cda3101lects/index.html
Locality of reference: the tendency of programs to access a relatively small portion of the
available memory at any given time.
temporal locality, states that individual memory locations once referenced are likely to be
referenced again. recently accessed data is likely to be accessed again soon. reuse
previously accessed data, reducing the need to fetch it from main memory. It is also known
as locality in time. Each time same useful data comes into execution.
spatial locality, states that if a location is referenced, then it is likely that nearby locations
will be referenced as well. Data tends to be accessed in contiguous or nearby memory
locations. subsequent memory accesses are likely to be within the same cache line,
resulting in cache hits and faster access times.It is also known as locality in space.Each
time new data comes into execution.
https://www.geeksforgeeks.org/difference-between-spatial-locality-and-temporal-locality/
http://ece-research.unm.edu/jimp/611/slides/chap5_3.html
○ lw
○ sw
● arithmetic-logical instructions
○ add
○ sub
○ and
○ or
○ slt
● control instructions
○ beq
○ j
● A processor consists of
○ datapath - processes the data signals (read, manipulate, store)
○ control - commands the data path by using control signals
● Types of Implementations
○ single cycle
○ multiple cycle
○ pipelined
2022 May
Why Upgrade PC
HDD to SSD: faster data access speeds, reduced boot times, improved overall system
responsiveness, better durability, lower power consumption, and quieter operation.
RAM: smoother multitasking simultaneously without slowing down, quicker application
launch times, and improved overall system responsiveness. Run memory-intensive
applications and games more efficiently
Processor: for faster computing speeds, improved multitasking capabilities, and enhanced
performance in resource-intensive tasks like gaming, video editing, and 3D rendering.
upgrading the Graphics card: for better gaming or graphic design capabilities
improving cooling with better fans or a liquid cooling system.
Non-volatile Memory: ROM retains its data even when power is turned off, making it
suitable for storing critical firmware or software that needs to be retained across
power cycles.
Security: ROM can be used to store sensitive code or data that needs to be protected
from unauthorized access or modification since it cannot be easily altered once
programmed.
Reliability: ROM is typically more reliable compared to other types of memory like RAM
(Random Access Memory) because it is not susceptible to data corruption or loss
due to power failure or electrical disturbances.
Cost: ROM tends to be cheaper than other non-volatile memory alternatives such as
Flash memory. For mass-produced embedded systems, cost considerations often
drive the choice of memory technology.
Speed: Registers are the fastest storage locations in a computer system, residing
directly within the CPU. Accessing data from registers is much quicker than
accessing data from primary memory (RAM). Since the CPU frequently requires
immediate access to operands and intermediate results during instruction execution,
using registers minimizes the latency associated with fetching data from slower
memory.
Operand Storage: Registers store operands for arithmetic and logical operations
performed by the CPU. When executing instructions, the CPU fetches data from
registers, performs computations, and stores results back into registers. Having
registers dedicated to storing operands allows for efficient manipulation of data
without repeatedly accessing primary memory.
Control Signals: Registers store control signals and status information that govern the
behavior of the CPU and other components. For example, the status register may
contain flags indicating the outcome of arithmetic operations (e.g., zero, carry,
overflow), while control registers may hold configuration settings for system
operation (e.g., mode settings, interrupt enable/disable).
Context Switching: Registers play a vital role in context switching, where the CPU
switches between executing multiple processes or threads. During context switches,
the CPU saves the current state of registers for the current process/thread and
restores the state of registers for the next process/thread. This enables seamless
multitasking and efficient utilization of system resources.
I/O Operations: Registers are used to interface with input/output (I/O) devices. Special-
purpose registers, such as data and control registers, are employed to transfer data
between the CPU and I/O devices, initiate I/O operations, and monitor device status.
CPU Internal Operations: Registers are utilized for various internal operations within the
CPU, including instruction decoding, address generation, and temporary storage of
data and instructions during execution. Having dedicated registers for these
purposes enhances the efficiency and performance of the CPU.
State one item that needs to be stored in ROM and give a reason why ROM is used
BIOS (1) as ROM is non-volatile and the BIOS is needed just after the power supply is
turned on (when RAM would be empty)
State one item that needs to be stored in RAM and give a reason why RAM is used
currently running programs (1) because RAM has quick access speeds (1) / RAM is read &
write (1)
Registers
high-speed temporary storage area built directly into the processor or CPU , stores data,
addresses and instructions for quick processing.help process data efficiently.
They are used to store operands, intermediate results, memory addresses, control flags, and
other essential data needed for processing instructions.
● Fetch: The CPU fetches instructions from memory into registers (e.g., IR).
● Decode: Instructions are decoded, and operands are fetched from memory into data
registers.
● Execute: The CPU performs arithmetic, logical, or control operations using the data
stored in registers.
● Write-back: Results are stored back into registers or memory.
Types of Registers:
● Data Registers:
● Accumulator (ACC): Often used as a primary data register for arithmetic and logical
operations. The result of most arithmetic operations is stored here.
● General-Purpose Registers (GPRs): Versatile registers that can hold data operands
or memory addresses. They are used for temporary data storage and manipulation.
● Floating-Point Registers (FPRs): Dedicated registers for performing floating-point
arithmetic operations, commonly used in scientific and engineering applications.
● Address Registers: Store memory addresses or pointers used for accessing data in
memory.
● Memory Address Register (MAR): Holds the memory address of data to be read
from or written to in the main memory.
● Memory Data Register (MDR): Holds the data being transferred between the CPU
and memory. It stores the data temporarily during read or write operations.
● Control Registers: Manage control signals, status flags, and mode settings that
govern the behavior of the CPU.
● Program Counter (PC): Holds the memory address of the next instruction to be
fetched and executed.
● Instruction Register (IR): Stores the current instruction fetched from memory,
awaiting decoding and execution.
● Status Register (SR): Contains flags indicating the outcome of arithmetic operations
(e.g., zero, carry, overflow) and system status (e.g., interrupt enable/disable)
● Special-Purpose Registers:
● Instruction Pointer (IP): Similar to the PC, it holds the address of the next instruction
to be executed, commonly used in some CPU architectures.
● Control and Status Register (CSR): Contains control bits and status flags for
configuring CPU operation and monitoring system status.
● Operand Storage: Registers hold operands for arithmetic, logical, and data
manipulation operations performed by the CPU.
● Temporary Storage: Intermediate results of calculations are stored in registers during
instruction execution.
● Address Calculation: Registers hold memory addresses or pointers for accessing
data in main memory or other storage devices.
● Control Signals: Control registers store flags and control signals that influence the
behavior of the CPU, such as the carry flag, zero flag, and interrupt enable/disable
flags.
● Instruction Execution: Registers facilitate the decoding, fetching, and execution of
instructions by holding the current instruction (IR) and the address of the next
instruction to be executed (PC).
● Context Switching: Registers are used to save and restore the state of the CPU
during context switches between different processes or threads.
● Input/Output Operations: Registers interface with I/O devices, transferring data
between the CPU and peripheral devices.