National Institute of Technology, Durgapur: Submitted By: Vipin Saharia (10/MCA/11) Submitted To: Prof. P. Chaudhary
National Institute of Technology, Durgapur: Submitted By: Vipin Saharia (10/MCA/11) Submitted To: Prof. P. Chaudhary
Assignments File
Computer architecture:
It may also be defined as the science and art of selecting and interconnecting
hardware components to create computers that meet functional, performance
and cost goals.
For example, in a multimedia decoder, the designers might need to arrange for
most data to be processed in the fastest data path and the various components
are assumed to be in place and task is to investigate the organizational structure
to verify the computer parts operates.
The computer organization and features also affect the power consumption
and the cost of the processor.
Assignment 2. How to overcome the drawbacks of Direct Mapping. Discuss
other mapping techniques also.
Associative mapping stores both content (data) and address of the memory
word.
The address is stored in argument register and memory searches for
matching address, if found we call it a HIT else MISS.
If MISS occurs, then it accesses the content from main memory and one
copy of address-data pair is transferred to associative cache memory.
If cache is found to be full, then through replacement policy i.e. FIFO, a
removal occurs and stores there.
It is an expensive mapping technique as logic is associated with each cell for
matching address-data pair.
This type of memory is accessed simultaneously and in parallel on the basis of the
data content rather than by specific address or location. When a word is written
in CAM, no address is given. The memory is capable of finding an empty unused
space or location to store a word.
While searching for the data, the memory locates all words which match
the specified content and marks them for reading.
In a system that utilizes a dynamic memory map, CAM can be used to store
memory addresses for quicker access.
Actually, Content-addressable memory (CAM) is a special type of computer
memory used in certain very high speed searching applications.
Because a CAM is designed to search its entire memory in a single
operation, it is much faster than RAM in virtually all search applications.
There are cost disadvantages to CAM however. Unlike a RAM chip, which
has simple storage cells, each individual memory bit in a fully parallel CAM
must have its own associated comparison circuit to detect a match
between the stored bit and the input bit.
Additionally, match outputs from each cell in the data word must be
combined to yield a complete data word match signal. The additional
circuitry increases the physical size of the CAM chip which increases
manufacturing cost. The extra circuitry also increases power dissipation
since every comparison circuit is active on every clock cycle. Consequently,
CAM is only used in specialized applications where searching speed cannot
be accomplished using a less costly method.
When a program tries to access pages that are not currently mapped to
physical memory (RAM). This situation is known as a page fault.
To resolve thrashing due to excessive paging, a user can do any of the following.
Locality of reference:
Locality of reference, also known as the principle of locality, is the phenomenon
of the same value or related storage locations being frequently accessed. There
are two basic types of reference locality. Temporal locality refers to the reuse of
specific data and resources within relatively small time durations. Spatial locality
refers to the use of data elements within relatively close storage locations.
Sequential locality, a special case of spatial locality, occurs when data elements
are arranged and accessed linearly, e.g., traversing the elements in a one-
dimensional array.
Assignment 5. Why pointers are used in spite they use two memory cycles.
In Multi-tasking environment, there are multiple programs running in
memory and there is a possibility of conflict if two programs simultaneously
access the machine resources. To prevent this, Windows does not permit
any application direct access to any machine resource. To channelize the
access without resulting into conflict between applications several new
mechanisms were created in the Microprocessor & OS. This had a direct
bearing on the way the application programs are created using pointers.
Since users have become more demanding, modern day applications have
to contend with these demands and provide several features in them. To
add to this, under Windows several such applications run in memory
simultaneously. The maximum allowable memory—1 MB—that was used in
16-bit environment was just too small for this. Hence Windows had to
evolve a new memory management model. Since Windows runs on 32-bit
microprocessors each CPU register is 32-bit long. Whenever we store a
value at a memory location the address of this memory location has to be
stored in the CPU register at some point in time. Thus a 32-bit address can
be stored in these registers. This means that we can store 2 32 unique
addresses in the registers at different times. As a result, we can access 4 GB
of memory locations using 32-bit registers. As pointers store addresses,
every pointer under 32-bit environment also became a 4-byte entity.
Advantages of Pointers:
Optimization: Pointers provide a performance advantage by allowing you
to access computer memory directly. This technique is commonly used to
optimize algorithms requiring frequent or repetitive access to large
amounts of data.
Function Parameters: Functions can return only one value, but they can
take multiple parameters. By passing in pointers to variables as parameters,
a function can be used to set the values of those variables, and the new
values will persist after the function returns. Being able to set the value of
several variables at once with a single function call is clean and efficient.
However, it can be a little confusing to read because you can't tell if the
variables passed in will be modified or not simply by looking at the function
call.
Function Pointers: Pointers are not just for objects in memory; they can
also be used for functions, thus allowing a function to be passed as a
parameter to another function. A function pointer can be assigned the
address of one of a choice of functions so that the pointer acts as a kind of
alias. Object-oriented programming languages have eliminated the need for
function pointers with inheritance and polymorphism.
These advantages are so essential and powerful tool for computer memory
management and programming thus hides its disadvantage of using two memory
cycles.
MVI D, 8BH
MVI C, 6FH
MOV A, C
ADD D
HLT
LXI H, FC30H
MOV B, M
INX H
MOV C, M
HLT
DATA
FC30 – 11H (Contained in B)
FC31 – 12H (Contained in C)
MVI A, 05H
INR, A
STA FC50H
HLT
DATA
FC50H – 06H
DATA
2501H – F8H
2502H – 9BH
RESULT
2503H – 5DH
LXI H, 2502H
MVI A, 99
SUB M
INR A
DCX H
ADD M
DDA
STA 2503H
HLT
DATA
2501H – 96D
2502H – 38D
RESULT
2503H – 58D
DATA
2301H
7314H
RESULT
5051H – 9615H
4080H – CARRY (If Any)
Amongst all implementation of virtual memory divides the virtual address space
of an application program into pages. With each page at least 4KB. Page tables
are used to translate the virtual address seen by the application program into
physical address.
1. A System with smaller page size uses more pages requiring a page table that
occupies more space.
3. When transferring from disk much of the delay is caused by seek time. Because
of this large sequential transfers are more efficient than several small transfers.
Thus transferring the same amount of data from disk to memory often requires
less time with larger pages than with smaller pages.
Besides this advantage there is also a disadvantage of having larger page size.
There are 128 segments. So 7 bits must be used for segment number.
There are 32 pages. So 5 bits must be used to represent the page number.
There are 4K word in each page i.e. 2^12 words. So 12 bits must be used to
represent the word number.
For physical address: There are 4K blocks i.e. 2^12 blocks. Therefore 12 bits must
be used to represent the block number.
Also there are 4K words in each block. Therefore 12 bits must also be used for
word number of each block.
Q) A virtual memory has page size of 1K words. There are eight pages and four
blocks. The associative memory page table contains the following entries.
PAGE BLOCK
1 3
2 1
4 2
6 0
Make a list of all virtual address that will cause a page fault if used by the CPU.
Sol:-
Since there are 8 pages. These 8 pages can be represented by 3 bits(0 to 7). Also
there are 1K words in each page that can be represented by 10 bits. There are 18
bits in the logical address.
c. If a page consists of 2k words, How many pages and blocks are there in the
system?
Sol:-
No. of words in address space is = 2^24=16M.
4 2 0 1 2 6 1 4 0 1 0 2 5 7
Determine the four pages that are resident in main memory after each page
reference change if the replacement algorithm used is a. FIFO
b.LRU
Sol:-
FIFO
4 4
2 4 2
0 4 2 0
1 4 2 0 1
2 4 2 0 1
6 6 2 0 1
1 6 2 0 1
4 6 4 0 1
0 6 4 0 1
1 6 4 0 1
0 6 4 0 1
2 6 4 2 1
3 6 4 2 3
5 5 4 2 3
7 5 7 2 3
LRU
4 4
2 4 2
0 4 2 0
1 4 2 0 1
2 4 2 0 1
6 6 2 0 1
1 6 2 0 1
4 6 2 4 1
0 6 0 4 1
1 6 0 4 1
0 6 0 4 1
2 2 0 4 1
3 2 0 3 1
5 2 0 3 5
7 2 7 3 5
Q ) Give the binary number of the logical address formulated in problem 7 for
segment 36 and word number 2000 in page 15.
Sol:-
The segment no. will be represent by 7 bits which must equal 36. So these 7
bits are 0100100.
The word no. Is represented by 12 bits which must equal to 2000.So these 12 bits
are 011111010000.