Wednesday, January 13, 2016

Definitions/Answers to the sample exam

Multiple Choice:

1. Instruction decoder: Decodes an opcode (or, translates instruction to

Can be implemented in hardware or micro-software

2. Cache memory: Much faster than RAM, very close to the CPU, sRAM technology (uses flip-flops).


Cache works like a buffer that stores data to go to RAM and data coming from RAM



3. Interleaving: A trick that enables CPU to store and read information RAM's memory banks 


4. Overheating of the tiny, crammed electronic components is the biggest problem when making new chips.

5. An ER diagram:

- Does NOT describe how a program works
- Does NOT contain info about the records of the database
- Is used be both the database designer and the customer

6. SQL syntax:

WHEN category = 'goat' OR category = 'tennis'
The rest two are wrong

7. A primary key

- Can be composed by more than one fields (composite primary)
- Can NOT have the same value in more than one row
- Is very important in making relations between tables
- Can be defined in different ways (NOT uniquely defined) but once you define it you have to stick with the attribute/attributes that make it.

8. An interrupt is a signal from an I/O device to the CPU asking for attention

- CPU can ignore maskable interrupts
- CPU can NOT ignore NON-maskable interrupts (they have priority over running programs)


9. If many interrupts come to the CPU at the same time

- CPU can not handle them at the same time
- CPU gives grants to accept interrupts
- The highest priority I/O will receive a grant and pass the signal to the next device
- They can not hear from each other and self regulate

10.  To send data to I/O devices a request (a system call) is sent to the operating system.
The I/O device needs an address to communicate with the I/O interface. The I/O card handles the data.


11. Low level programming languages:

- Are close to the hardware/circuits/machine language
- Only understand very few nstructions
- Are really hard to write code on
- That's why we use easier high level languages
- High level language is converted to low level
- Different CPUs understand different low-lvl languages

12. The Scheduler: Decides which process will be served when (scheduling) in order to maximize efficiency.



13. The Data Register contains the data to be stored in the computer storage (e.g. RAM), or the data after a fetch from the computer storage.
- It does not contain any specific instructions it's just a 'bucket' that stores data temporarily.14. Hints for algebra with different numeric systems:
- Octal positive integers need 3 bits per digit.
- Hexadecimal positive integers need 4 bits per digit.
- Binary positive integers need one bit per digit.
- We multiply bits/digit with nr. of digits, e.g (2AD6 needs 4bits*4bits/digit = 16 bits to be stored)
- If we don't have enough bits to store a number we have overflow.


15. Virtual memory is memory from the Hard Disk Drive that plays the role of RAM when the computer needs more main memory. We can decide how much virtual memory we want to have available. It is slower than RAM.

16. Databases store their data outside the programs, so programs and data become independent of each other. Nuff said.

17. Direct memory access (DMA) is a feature that allows some hardware (I/O) to access main system memory (RAM) independently of the CPU.

The CPU first starts the transfer, then it does other work while the transfer is in progress, and finally receives an interrupt from the DMA controller when the operation is done. It's useful when the CPU cannot keep up with the rate of data transfer, or when the CPU needs to perform useful work while waiting for a slow I/O data transfer. 


18. CPU needs address to communicate with memory and I/O devices.



19. CUSTOMER ( ID, Name, MailAddress, TelNr)

PROBLEM (ID, date, description, cameraSerialNr, CameraStatus, customerID)
CAMERA (cameraSerialNr, brand, imageSensor, pixels, ISOSensitivity)
SELECT name, cameraSerialNr
FROM CUSTOMER INNER JOIN PROBLEM
ON CUSTOMER.ID = problem.customerid
WHERE camerastatus <> 'old'

The fucker tried to join on different fields which ain't make no join at all, duh!

< > means not equal to

20. The fetch and execute cycle reads and writes data from/to the memory.


________________________




Questions:

1. When writing and reading data (to or from memory or external devices) we would like to know if these operations were carried out without errors. Explain what principle can be used to develop error detection and error correction. Illustrate this with an example.



There are many ways to implement error detection and correction. The core idea of some is using parity bits.

Using one parity bit for error detection goes as following:

Each packet of bits of specific length has one bit that ensures that the total number of '1' bits are odd.

So, if the data-bits of '1' are odd the parity bit is '0' and if the 'data' 1-bits are even the parity bit is '1' to make everything even.

The reader expects always odd number of ones per packet so if he sees even number he knows there has been an error. 

That is called odd parity. Even parity works exactly the same way only now the parity bit ensures the number of ones are even.

We can have more than one parity bits per packet and more sophisticated techniques like Hamming code to not only get better detection but even correct the errors.

In modern communication it may be enough to just detect the errors and when found request a re-send because errors aren't that frequent.

Here's a simple example of a 4-bit packet with odd parity. The last bit is the parity bit.

Sender sends 0111, the parity bit is '1' to keep the parity odd.
Receiver receives 0011 (somehow the 2nd bit became '0'). Since odd parity is agreed, the receiver knows that something went wrong as there is even number of 1-bits (2), so he can request re-send of the packet



2. Many webpages refer to UTF-­8 in the first lines. This is a Unicode encoding scheme using variable length encoding . What is this? Explain using an example.

To encode all the different characters from different languages we need lots of bits. But, using many -say, 64- bits for each character is a huge waste of memory if we don't use more than the most common ones.

UTF-8 allows us to use as many 8-bits (bytes) for each character as needed.

For example, English letters will use only one byte each but emojis that are in recent huge collections of symbols may use 4 or even 5 bytes each.

In order for the computer to know where to stop reading a character there are some bits in the beginning that denote how many of the following bytes will be used for that character.

For example, 01XXXXXX.... is 1 byte/char
110XXXXX 10XXXXXX is 2 bytes/char
1110XXXX 10XXXXXX 10XXXXXX is 3 bytes/char
etc


3. Cache memory will increase the speed of memory. How does it work?

Cache is a sort of buffer memory that helps the CPU access information much faster than in RAM. Cache writes and reads from RAM. Cache ideally contains data that the CPU uses frequently so it doesn't have to reach all the way to RAM.

Cache is organized in levels of proximity L1 (closest) L2, L3 etc, the closer to the CPU the chip is the faster it is.
L1 communicates with L2 which communicates with L3 which can communicate to RAM if there's no other level.

Cache, is much faster than main memory (RAM).
It's built with a much faster technology (Static RAM as opposed to DRAM of main memory). It's also much closer to the CPU (inside the CPU chip).

Cache is also way more expensive than main memory.

4. When you switch off a computer, all the content of the memory is lost. How is it possible to startup the computer again, since there is no program available in memory anymore?

Well, thankfully the computer contains non volatile memory called ROM (Read Only Memory). 

ROM is already written when we get the computer and contains the BIOS (basic input/output system) and generally everything needed to startup the computer, have access to the keyboard and screen and start loading the operating systems.

ROM can not be erased/rewritten by the computer.

Sometimes the non volatile information stored in ROM is called the firmware of the computer (or some device that may use such memory)



5. Relational databases store their data in different tables. Still they are able to combine the
information from different tables. How does it work? Explain using an example.

Each of the tables of a relational database must have a field or a unique combination of fields defined as 'primary key'. That will uniquely define each of the other attribute values of a record.

In order for a table to relate with another, one or more attributes will be defined with the same name as the primary key of a different table, and will be taking values that exist in the records of that primary key. Those attributes are called foreign keys.

So, we can uniquely identify fields of a different table if in our table there is a foreign key of the one we want to relate with.

Example of two tables:



PERSON

Human_ID Primary key
1
2
3
Name
Patrick
Bob
Squid
Phone_Number
67985433
4853948
3873049

TEACHES

Course_ID Primary key
Computerologly
Databaseball
Goats
Difficulty
Toughie
It’s_ok
gweeeeh!
Human_ID  Foreign Key
1
1
1



In this case the primary key Human_ID of PERSON is a foreign key in TEACHES.

So at any moment, if we have the table TEACHES we can access the profile of the Human who teaches some course we want to check asking ‘to whom my foreign key is primary and what does that record give?’.



6. Rounding errors can be a problem when entering decimal data in a computer. Why?
Explain if this is always a problem. Use an example!




Floating-point numbers are represented in computer hardware as base 2 (binary) fractions. 

For example, the decimal fraction 0.125  has value 1/10 + 2/100 + 5/1000, and similarly the binary fraction
0.001 has value 0/2 + 0/4 + 1/8. 

(0.125)10 = (0.001)2

These these are two identical decimal numbers, just the first is written in base 10 fractional notation, and the second in base 2.

Unfortunately, most decimal fractions cannot be represented exactly as binary fractions.

So, the decimal floating-point numbers you enter are usually only approximated by the binary floating-point numbers that are actually stored in the machine.

No matter how many base-2-digits we use, the decimal value 0.1 cannot be represented exactly as a base 2 fraction. 

In base 2, 1/10 is the infinitely repeating fraction
0.000110011001100110011...

So we stop at any finite number of bits, and you get an approximation.

There rounding errors can be ok in addition and subtraction but in multiplication (and divisions) they often greatly escalate and give results with big errors/ many unreliable digits.

No comments:

Post a Comment