Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
14/12/15 17:17
1.
a) Explain how parameters and results are passed between
C++ and Assembly language subroutines.
The C++ program puts the parameters on the stack, and the assembly
subroutine gets them through the register that has the address of the
top of the stack.
The return value, when its 32-bit long, its returned through the EAX
register. When its 64-bit long, its return through both EAX and EDX
registers.
b) Explain the terms base class and derived class as used in the
C++programming language and hence give reasons for their
popularity.
Assuming that theres a class in the program which describes a person,
and at some point, a student must be represented. So, in that case,
person will be a base class for the creation of the derived class
student. Instead of creating a whole new class to student, its just
needed to create it like a derivation of a person, in which itll be added
the new features (like a student id or grades), but the student class
will have every characteristic that the person class has. This is so
popular because it brings optimisation to the code and its possible to
make comparisons and attributions between the two classes.
c) Give a reason for the use of virtual functions in C++. Hence
explain the term abstract base class and why it is such a useful
concept.
Virtual functions: When having a lot of classes in a program, specially
when theres inheritance involved, it is possible to have two different
classes with same method names. The problem is when one class is
derived from another and the implementation of this methods differs
between the two classes. In that case, the compiler normally decides
which function to call during compiling time, and it calls for the base
class function. But the programmer (and/or the user) usually wants to
have the derived class method. To solve this, its necessary to
postpone the decision of which method will be called until running
time, and that way, the program will correctly associate the type of the
variable with its class and call the correct method.
Base class: Abstract base classes happen when the base class dont
need to be represented itself in the main program. The programmer
needs to create a lot of objects of different classes, but they are all
similar. In that case, a base class is created, from which a lot of
derived classes will be created. But when the base class wont be used
to create an object in the program, its an abstract base class.
2.
a) In the context of the interface between DRAM memory chips
and the CPU, give reasons for use of the following:
(i) refresh counter (ii) address multiplexer
Refresh counter: Dynamic RAM uses every single bit as storage. After
all of its bits are filled, they need to be refreshed to make sure that
that information remains correct, hence its capacitors loose charge
with the time, but all the bits are in used. The refresh counter is to
know which row of bits is going to be refreshed at that time.
Address Multiplexer: In the memory, theres lines and columns,
resulting in 2 different addresses. So, a multiplexer is used to control
which one is being passed.
b) Comment on the connection between DRAM access time and
the use of cache memory in a computer system.
The DRAM access time is big, so it cant be used for the CPU to
continuous access. Although, a small amount of cache memory used is
enough to supply the big majority of CPU memory access.
c) Why is Dynamic RAM used as main memory in a computer
system rather than Static RAM? Draw a block diagram that
shows how a CPU would be interconnected with a DRAM based
memory system.
DRAM holds more memory for area than SRAM, and thats why its
used as main memory. SRAM is faster, so its used in the cache.
Data Link Layer: Its an intermediate layer between the other two and
deals with error detection and correction.
Physical Layer: Its literally the physical components of the PCIe, e.g.
its pins.
c) The PCI-Express 3.0 standard is capable of an interconnect
bit-rate for a single lane of 8 GT/s (Giga Transfers per second)
in each direction. Calculate if it possible to achieve a usable
bidirectional transfer rate of 15GBytes/sec using 16 PCIExpress lanes.
Starting with:
1 lane has two directions, so 16GB/s. But for each 128 bits, it actually
has to send 130 bits. So, (128/130)*16 = 15,7 GB/s.
This is just for one lane. For 16 lanes: 252 GB/s.
Divided by 8, it returns 31.4 GB/s bi-directional data transfer, which
means that is possible to have 15GB/s using PCIe x16.
d) The block diagram in Figure 1 below shows a scenario where
2 CPUs each have local private buses with local memory and
local I/O. They also share a block of global memory which they
can use to pass data to each other. Describe the sequence of
events when CPU 1 begins execution of the instruction that
attempts to load the byte contents of location hex C0000000
into one of its internal registers
14/12/15 17:17
14/12/15 17:17