Thursday, January 13, 2011

August 2007 - Comp Org & Soft Sys

------------------------------------------------------------------------------------------------------------------
 
What is the use of control memory? Differentiate between microinstruction sequencing and microinstruction execution.


------------------------------------------------------------------------------------------------------------------

Does disk striping improve I/O request rate performance compared to a comparable disk array without striping?
If a single I/O request consists of multiple logically contiguous strips, then up of 'n' strips of data can be handled in parallel, greatly reducing the I/O transfer time.

------------------------------------------------------------------------------------------------------------------
What is bus arbitration? What is the difference between synchronous and asynchronous bus.

------------------------------------------------------------------------------------------------------------------

Redundant Array of Independent Disks - RAID

The last ten years have witnessed a massive increase in the performance level of PC network workstations and servers. Electronic advances have enabled CPU and video performance to improve 50 to 100 times. However, mechanically bound disk I/O performance has become an ever increasing bottleneck. Disk I/O performance has only improved by about five times over the same period. This performance mismatch will only worsen as we implement ever more demanding applications such as image processing, CAD, database, and data acquisition.

Even more importantly, data reliability and availability must be assured as more and more mission critical applications migrate to LANs. Drive manufacturers have made great advances in disk reliability. The MTBF (Mean Time Between Failure) for these drives has also increased (although perhaps not as much as the marketing arms of the drive makers might like to claim). Even though the likelihood of a drive failure has decreased, many critical applications cannot afford any system downtime. Many corporations have found that implementing some form of data redundancy can help to guard against the risk of a drive failure.

Network administrators are continually seeking ways to improve system performance and reliability. One method of achieving these dual and often opposing goals is to use RAID (Redundant Array of Independent Disks) technology.

Why RAID?
Disk I/O is relatively slow because it is mechanical. A disk read or write involves two processes. First positioning the R/W head, and second transferring the information to/from the disk. Head positioning is limited by seek time and disk rotation to the start of the data (rotational latency). Data transfer occurs one bit at a time and is limited by the speed of rotation and the density of the data. One method that can be used to speed the transfer of data is to use many disks in parallel. For example, if a disk is capable of a given number of I/O transactions per second, then two disks are theoretically capable of twice that many. Similarly, if one disk can transfer a certain amount of data, then two disks acting together can transfer twice as much data. Additional disks would continue this increase in I/O capability until some other component of the computer system became the limiting factor.

System managers often try to accomplish this by manually spreading data among several disks so that each disk receives a somewhat equal share of the system load. 
This I/O tuning process can yield good results but is limited by two factors:
(1) It doesn’t speed the transfer of data for a single file; it only increases the number of files being accessed concurrently. And 
(2) system I/O demands change minute-to-minute; it is rarely perfectly balanced and certainly won’t stay that way over time.

A disk array can provide better performance because it automatically divides a read/write request among its member disks. For example, if a read/write request involved four 4KB blocks of data, then four disks operating in an array could theoretically provide four times the transfer rate of a single drive because each drive would only need to handle one block of data and they could each operate at the same time. In practice the total throughput would not be quite that high due to the overhead of managing four drives. Additionally, data redundancy can be built into a disk array, which protects against drive failure. It is this redundancy which creates a RAID array. And the different ways in which this redundancy can be achieved results in different levels of RAID. Each RAID level has benefits and tradeoffs, explained below.  

Parallel vs. Independent Access Arrays
Parallel Access Arrays. Parallel access arrays are arrays in which every member disk participates in every I/O operation. They provide a high data transfer rate because the data for any given read/write operation is spread among the member disks and is accessed simultaneously. The data transfer rate will be approximately equal (within 5%) to the sum of the transfer rates of the member disks. The disk I/O rate (number of individual read/writes per second) is similar to the I/O rate for a single disk, because the disks in a parallel access array work in unison to access only one block of data at a time. In other words, a parallel access array will access only one file at a time, but will do so at a very high transfer rate. Some implementations of parallel access arrays also require synchronized rotation of member disks. Disk synchronization requires disks that support this feature. RAID levels 2 and 3 are parallel access arrays.

Independent Access Arrays. Independent Access Arrays are arrays in which the member disks operate independently, even to the extent of satisfying multiple I/O requests concurrently. They provide a high disk I/O rate because each disk can be servicing a separate I/O request. The disk I/O rate will be approximately equal (within 5%) to the sum of the I/O rates of the member disks. The data transfer rate for a given block is the same as the transfer rate for a single disk because each block is stored on only one member disk. The total system transfer rate for an independent access array is similar to a parallel access array but may be split between several unrelated I/O requests. RAID levels 4 and 5 are independent access arrays. RAID levels 0 and 1 may be either parallel or independent but are usually implemented as independent arrays.

Which level is best
The best implementation depends on many factors, including cost, I/O transfer load, I/O transaction rate, and the ratio of reads to writes for you system. The following chart summarizes the characteristics of each level:

RAID Level 0
Very high transfer rate, but an increased risk of data loss
RAID Level 1
Very high data availability but incurs a 50% cost in storage space.
RAID Level 0 & 1
Both the benefits of level 0 and level 1—high transfer rate and high data availability—but incurs a 50% cost in storage space
RAID Level 2
not commonly used
RAID Level 3
Very high data transfer rate, I/O rate similar to that of a stand-alone disk at a cost of 1 drive
RAID Level 4
The read/modify/write cycle for the dedicated parity drive induces such a performance penalty that RAID level 5 is always a better choice for an independent access array
RAID Level 5
Transfer rate higher than that of a single device but lower than that of level 3, very high I/O transaction rate at a cost of 1 drive

A redundant storage system does not lessen the necessity for adequate system backups.
RAID levels greatly improve performance of disk storage systems. At the same time, greater data reliability and availability can be achieved. All at a reasonable cost.



Wednesday, January 12, 2011

August 2008 - Comp Org & Soft Sys

------------------------------------------------------------------------------------------------------------------

In the context of RAID what is the distinction between parallel access and independent access?
Parallel Access Arrays. Parallel access arrays are arrays in which every member disk participates in every I/O operation. They provide a high data transfer rate because the data for any given read/write operation is spread among the member disks and is accessed simultaneously. The data transfer rate will be approximately equal (within 5%) to the sum of the transfer rates of the member disks. The disk I/O rate (number of individual read/writes per second) is similar to the I/O rate for a single disk, because the disks in a parallel access array work in unison to access only one block of data at a time. In other words, a parallel access array will access only one file at a time, but will do so at a very high transfer rate. Some implementations of parallel access arrays also require synchronized rotation of member disks. Disk synchronization requires disks that support this feature. RAID levels 2 and 3 are parallel access arrays.

Independent Access Arrays. Independent Access Arrays are arrays in which the member disks operate independently, even to the extent of satisfying multiple I/O requests concurrently. They provide a high disk I/O rate because each disk can be servicing a separate I/O request. The disk I/O rate will be approximately equal (within 5%) to the sum of the I/O rates of the member disks. The data transfer rate for a given block is the same as the transfer rate for a single disk because each block is stored on only one member disk. The total system transfer rate for an independent access array is similar to a parallel access array but may be split between several unrelated I/O requests. RAID levels 4 and 5 are independent access arrays. RAID levels 0 and 1 may be either parallel or independent but are usually implemented as independent arrays.

------------------------------------------------------------------------------------------------------------------

What is the difference between EPROM, EEPROM and Flash memory? Explain in brief.

------------------------------------------------------------------------------------------------------------------

What are the advantages of memory mapped I/O over isolated I/O?
A memory mapped peripheral device is connected to the CPU's address and data lines exactly like memory, so whenever the CPU reads or writes the address associated with the peripheral device, the CPU transfers data to or from the device. This mechanism has several benefits and only a few disadvantages.


The principle advantage of a memory-mapped I/O subsystem is that the CPU can use any instruction that accesses memory to transfer data between the CPU and a memory-mapped I/O device. The MOV instruction is the one most commonly used to send and receive data from a memory-mapped I/O device, but any instruction that reads or writes data in memory is also legal. For example, if you have an I/O port that is read/write, you can use the ADD instruction to read the port, add data to the value read, and then write data back to the port. 

Of course, this feature is only usable if the port is a read/write port (or the port is readable and you've specified the port address as the source operand of your ADD instruction). If the port is read-only or write-only, an instruction that reads memory, modifies the value, and then writes the modified value back to memory will be of little use. You should use such read/modify/write instructions only with read/write ports (or dual I/O ports if such an operation makes sense). 

Nevertheless, the fact that you can use any instruction that accesses memory to manipulate port data is often a big advantage since you can operate on the data with a single instruction rather than first moving the data into the CPU, manipulating the data, and then writing the data back to the I/O port. 

The big disadvantage of memory-mapped I/O devices is that they consume addresses in the memory map. Generally, the minimum amount of space you can allocate to a peripheral (or block of related peripherals) is a four kilobyte page. Therefore, a few independent peripherals can wind up consuming a fair amount of the physical address space. Fortunately, a typical PC has only a couple dozen such devices, so this isn't much of a problem. However, some devices, like video cards, consume a large chunk of the address space (e.g., some video cards have 32 megabytes of on-board memory that they map into the memory address space). 

The advantage of an I/O address space is that peripheral devices mapped to this area do not consume space in the memory address space. This allows you to fully expand the memory address space with RAM or other memory. On the other hand, you cannot use arbitrary memory instructions to access peripherals in the I/O address space, you can only use the IN and OUT instructions. 


------------------------------------------------------------------------------------------------------------------

In virtually all systems that include DMA modules, DMA access to main memory is given higher priority than CPU access to main memory. Why?
Because the DMA runs slower than the processor and therefore potentially starves the processor of data which in turn wastes the processor resources (i.e. the processor becomes under utilised) and slows down the whole application. Furthermore, DMA requests are much less frequent than the CPU.  If the CPU were given priority, it would hog the access, preventing the DMA from ever making a request.  Secondly, I/O requests may have no buffer and data may be lost if the transfer is delayed.
------------------------------------------------------------------------------------------------------------------

Draw the state diagram of an instruction cycle with interrupts. Label all states clearly.



------------------------------------------------------------------------------------------------------------------

Tuesday, January 11, 2011

Cache Mapping and Associativity

A very important factor in determining the effectiveness of the level 2 cache relates to how the cache is mapped to the system memory. What this means in brief is that there are many different ways to allocate the storage in our cache to the memory addresses it serves. Let's take as an example a system with 512 KB of L2 cache and 64 MB of main memory. The burning question is: how do we decide how to divvy up the 16,384 address lines in our cache amongst the "huge" 64 MB of memory?

There are three different ways that this mapping can generally be done. The choice of mapping technique is so critical to the design that the cache is often named after this choice:

Direct Mapped Cache:
The simplest way to allocate the cache to the system memory is to determine how many cache lines there are (16,384 in our example) and just chop the system memory into the same number of chunks. Then each chunk gets the use of one cache line. This is called direct mapping. So if we have 64 MB of main memory addresses, each cache line would be shared by 4,096 memory addresses (64 M divided by 16 K).

Fully Associative Cache:
Instead of hard-allocating cache lines to particular memory locations, it is possible to design the cache so that any line can store the contents of any memory location. This is called fully associative mapping.

N-Way Set Associative Cache:
"N" here is a number, typically 2, 4, 8 etc. This is a compromise between the direct mapped and fully associative designs. In this case the cache is broken into sets where each set contains "N" cache lines, let's say 4. Then, each memory address is assigned a set, and can be cached in any one of those 4 locations within the set that it is assigned to. In other words, within each set the cache is associative, and thus the name.
This design means that there are "N" possible places that a given memory location may be in the cache. The tradeoff is that there are "N" times as many memory locations competing for the same "N" lines in the set. Let's suppose in our example that we are using a 4-way set associative cache. So instead of a single block of 16,384 lines, we have 4,096 sets with 4 lines in each. Each of these sets is shared by 16,384 memory addresses (64 M divided by 4 K) instead of 4,096 addresses as in the case of the direct mapped cache. So there is more to share (4 lines instead of 1) but more addresses sharing it (16,384 instead of 4,096).

Conceptually, the direct mapped and fully associative caches are just "special cases" of the N-way set associative cache. You can set "N" to 1 to make a "1-way" set associative cache. If you do this, then there is only one line per set, which is the same as a direct mapped cache because each memory address is back to pointing to only one possible cache location. On the other hand, suppose you make "N" really large; say, you set "N" to be equal to the number of lines in the cache (16,384 in our example). If you do this, then you only have one set, containing all of the cache lines, and every memory location points to that huge set. This means that any memory address can be in any line, and you are back to a fully associative cache.

Comparison of Cache Mapping Techniques
There is a critical tradeoff in cache performance that has led to the creation of the various cache mapping techniques described in the previous section. In order for the cache to have good performance you want to maximize both of the following:

Hit Ratio: You want to increase as much as possible the likelihood of the cache containing the memory addresses that the processor wants. Otherwise, you lose much of the benefit of caching because there will be too many misses.

Search Speed: You want to be able to determine as quickly as possible if you have scored a hit in the cache. Otherwise, you lose a small amount of time on every access, hit or miss, while you search the cache.

Now let's look at the three cache types and see how they fare:

Direct Mapped Cache:
The direct mapped cache is the simplest form of cache and the easiest to check for a hit. Since there is only one possible place that any memory location can be cached, there is nothing to search; the line either contains the memory information we are looking for, or it doesn't.
Unfortunately, the direct mapped cache also has the worst performance, because again there is only one place that any address can be stored. Let's look again at our 512 KB level 2 cache and 64 MB of system memory. As you recall this cache has 16,384 lines (assuming 32-byte cache lines) and so each one is shared by 4,096 memory addresses. In the absolute worst case, imagine that the processor needs 2 different addresses (call them X and Y) that both map to the same cache line, in alternating sequence (X, Y, X, Y). This could happen in a small loop if you were unlucky. The processor will load X from memory and store it in cache. Then it will look in the cache for Y, but Y uses the same cache line as X, so it won't be there. So Y is loaded from memory, and stored in the cache for future use. But then the processor requests X, and looks in the cache only to find Y. This conflict repeats over and over. The net result is that the hit ratio here is 0%. This is a worst case scenario, but in general the performance is worst for this type of mapping.

Fully Associative Cache:
The fully associative cache has the best hit ratio because any line in the cache can hold any address that needs to be cached. This means the problem seen in the direct mapped cache disappears, because there is no dedicated single line that an address must use.
However (you knew it was coming), this cache suffers from problems involving searching the cache. If a given address can be stored in any of 16,384 lines, how do you know where it is? Even with specialized hardware to do the searching, a performance penalty is incurred. And this penalty occurs for all accesses to memory, whether a cache hit occurs or not, because it is part of searching the cache to determine a hit. In addition, more logic must be added to determine which of the various lines to use when a new entry must be added (usually some form of a "least recently used" algorithm is employed to decide which cache line to use next). All this overhead adds cost, complexity and execution time.

N-Way Set Associative Cache:
The set associative cache is a good compromise between the direct mapped and set associative caches. Let's consider the 4-way set associative cache. Here, each address can be cached in any of 4 places. This means that in the example described in the direct mapped cache description above, where we accessed alternately two addresses that map to the same cache line, they would now map to the same cache set instead. This set has 4 lines in it, so one could hold X and another could hold Y. This raises the hit ratio from 0% to near 100%! Again an extreme example, of course. As for searching, since the set only has 4 lines to examine this is not very complicated to deal with, although it does have to do this small search, and it also requires additional circuitry to decide which cache line to use when saving a fresh read from memory. Again, some form of LRU (least recently used) algorithm is typically used.

Here's a summary table of the different cache mapping techniques and their relative performance:


Cache Type
Hit Ratio Search Speed
Direct Mapped Good Best
Fully Associative Best Moderate
N-Way Set Associative Very Good, Better as N Increases Good, Worse as N Increases

Monday, January 10, 2011

Feb 2010 - Comp Org & Soft Sys

What are the three performance parameters used for memories? Describe in brief.
From a users point of view, the two most important aspects of memory are capacity and performance.
Three performance parameters are,
1. Access time (latency):
2. Memory cycle time
3. Transfer rate

------------------------------------------------------------------------------------------------------------------

Explain in brief the difference between spatial and temporal locality
The basis for the performance advantage of two-level memory is a principle called Locality of Reference.
This principle states that memory references tend to cluster. Over a long period of time, the clusters in use change, but over a short period of time, the processor is primarily working with fixed clusters of memory references.

Spatial locality refers to the tendency of execution to involve a number of memory locations that are clustered. This reflects the tendency of a processor to access instructions sequentially. Spatial locality also reflects the tendency of processor to access data locations sequentially, such as when processing a table of data.

Temporal locality reflects to the tendency of a processor to access memory locations that have been used recently. For example, when an iteration loop is executed, the processor executes the same set of instructions repeatedly.

------------------------------------------------------------------------------------------------------------------

What are the relative advantages and disadvantages of unified cache versus split cache?
 During initial days a single cache is used to store references to both data and instructions. Now a days it became a norm to split the cache into two, one dedicated to data and one dedicated to instructions.

There are two potential advantages of a unified cache,
1. Only one cache needs to be designed and implemented.
2. For a given cache size, a unified cache has a higher hit rate than split cache because it balances the load between instructions and data automatically. That is, if an execution pattern involves more instruction fetch than data fetches, then the catch will tend to fill up with instructions and vice verse.

Despite these advantages the trend is towards split caches.
The key advantage of split cache design is that it eliminates the contention for cache between instruction fetch/decode unit and execution unit. This is important in any design that relies over the pipe-lining of instructions.

Typically the processor will fetch instructions ahead of time and fill a buffer or pipeline, with instructions to be executed. Assuming we have unified cache, when the execution unit performs a memory access to load and store data, the request is submitted to unified cache. If, at the same time, the instructions prefetcher issues a read request to the cache for an instruction, that request will be temporarily blocked so that the cache can service the execution unit first.

This cache contention can degrade performance by interfering with efficient use of the instruction pipeline.
The split cache structure overcomes this difficulty.

------------------------------------------------------------------------------------------------------------------

Explain the basic differences between direct mapping, associative mapping and set associative mapping in caches.


------------------------------------------------------------------------------------------------------------------

 Briefly describe the two approaches that can be used to deal with multiple interrupts.


------------------------------------------------------------------------------------------------------------------

What is the benefit of using multiple-bus architecture compared to single-bus architecture?

An on-chip bus may connect the processor and cache memory.
An on-board bus may connect the processor to main memory and other components.

If a great number of devices are connected to the bus, the performance will be greatly hit. There are two main reasons,
1.In general, more the devices attached to the bus, the greater the bus length and hence the greater the propagation delay. This delay determines the time it takes for devices to coordinate the use of bus. When control of the bus passes from one device to another frequently, these propagation delays can noticeably affect performance.
2. The bus may become a bottleneck as the aggregate data transfer demand approaches the capacity of the bus. This problem can be countered to some extent by increasing the data rate the bus can carry and by using wider buses (like increasing from 32 to 64 bits). However, because the data rates generated by attached devices are growing rapidly, this is a race that a single bus is destined to lose.



Traditional bus architecture is reasonably efficient but begins to break down as higher and higher performance is seen in I/O devices. In response to these growing demands, a new approach is to, build a high-speed bus that is closely integrated with the rest of the system, requiring only a bridge between the processor's bus and the high speed bus. This arrangement is also referred to as Mezzanine architecture.



The advantage of this arrangement is that the high speed bus brings high demand devices into closer integration with the processor and at the same time is independent of the processor. Thus, differences in processor and high-speed bus speeds and signal line definitions are tolerated. Changes in processor architecture do not affect the high-speed bus and vice verse.

------------------------------------------------------------------------------------------------------------------
A DMA module is transferring characters to memory using cycle stealing, from a device transmitting at 9600 bps. The processor is fetching instructions at the rate of 1 MIPS. By how much will the processor be slowed down due to DMA activity?

Presuming that the data width of the system bus is a byte, the DMA module will steal a cycle each time a byte has arrived. If the device receives 9600 bits per second, 1200 bytes will be received every second. The CPU will slow from 1 MIPS to (1,000,000-1200) Instructions per second.
 
------------------------------------------------------------------------------------------------------------------
 
Why is a two-stage instruction pipeline unlikely to cut the instruction cycle time in half, compared with the use of no pipeline?
There could be two possibilities:
a. The execution time will generally be longer than the fetch time. Execution will involve reading and storing operands and the performance of some operation. Thus, the fetch stage may have to wait for some time before it can empty its buffer.
b. A conditional branch instruction makes the address of the next instruction to be fetched unknown. Thus, the fetch stage must wait until it receives the next instruction address from the execute stage. The execute stage may then have to wait while the next instruction is fetched.
 
------------------------------------------------------------------------------------------------------------------