Merge branch 'staging' of https://gitlab.com/shockrahwow/csnotes into staging

This commit is contained in:
shockrahwow 2018-09-30 16:42:16 -07:00
commit 61b606e25c
4 changed files with 86 additions and 102 deletions

View File

@ -1,115 +1,45 @@
# lec9
This lecture has a corresponding activity found in `lab/` it is called `combinational-logic.md`.
It is more useful to practice combinational logic as opposed to read about it so the sub section here will be minimal in information.
It's recommended that you try as many of the problems in the activity until you understand the concept, _don't bother doing them all_.
## Combinational Logic
_Continuation of RDT_ + lec8
### OR
## Pipelining
`a+b` is equivalent to saying `a` or `b`.
Instead of sending just one packet at a time we can send N packets across the network simultaneously.
We have two choices to deal with errors in this case however, `go-back-N` or `selective repeat`.
### AND
### Go-Back-N
`ab` is equivalent to saying `a` and `b`.
THings we'll need to deal with:
Note that this syntax is simlar to multiplication so `a*b` is equivalent to the above.
* timeout
* recevier acknowledgement
### NOT
#### Sender
`!a` is equivalent to saying not `a`.
We can also denote it with a bar over the expression we want to _not_.
Sends N packets at a time and only re-sends according to highest value `ack` the receiver responds with.(_the next section explains this better_)
![Figure-Not](../img/not.png)
#### REceiver
### Big AND
Behavior is the same as an `and` but instead of two inputs we can have many more inputs.
It will only ever return a 1 if all inputs are 1.
### Big OR
Again we are mimicing the behvior of the normal or gate but this time we can have multiple inputs as opposed to just two.
If only one of the many inputs is 1 then we return a 1 for the output of the Big OR.
## Decoders
Here we'll learn by doing
```
Selector = 2 Bits
Output = 4 Bits
```
As a challenge you can try using the combinational logic gates from above to try and tackle this yourself
|s1 |s2 |o3 |o2 |o1 |o0 |
|---|---|---|---|---|---|
| 0 | 0 | 0 | 0 | 0 | 1 |
| 0 | 1 | 0 | 0 | 1 | 0 |
| 1 | 0 | 0 | 1 | 0 | 0 |
| 1 | 1 | 1 | 0 | 0 | 0 |
We will respond with the _highest_ successful sequence number.
Say we were supposed to get 1 2 3 4 but 3 failed.
This is when we send ack1 ack2 but not `ack3 or 4`.
This tells the sender to resend everything from 3 onwards.
## Multiplexor
### Selective Repeat
Typically we'll refer to multiplexors by their size.
Receiver gets `1 2 3 4` but `3` fails.
This time we send `ack1 ack2 nack3 ack4` and `3` is resent.
_This will take less bandwidth and still correct issues which can randomly happen._
> what does it do?
If we imagine a window moving along a row of packet slots we only move that window along the row as the lowest(sequenced) packet is filled.
If a packet isn't `ack`d we wait for a timeout then we resend to the receiver.
It takes a signal as `2^n` inputs and out puts out `n` signals as output.
Example: Say we send `1 2 3 4 5` but `3` is lost.
Example: We have a selector(s0), two inputs[in0 & in1], and one output `out`.
The selector will select an input and we will generate some output in `out`.
|s0 | i0 | i1 | out|
|---|---|---|---|
|0 | 0 | 0 | 0|
|0 | 0 | 1 | 1|
|0 | 1 | 0 | 0|
|0 | 1 | 1 | 1|
|1 | 0 | 0 | 0|
|1 | 0 | 1 | 0|
|1 | 1 | 0 | 1|
|1 | 1 | 1 | 1|
Our window would move from `1-5` to `2-7`, wait for timeout then resend, wait for `ack` then move forward as it receives `3`.
A useful link for visualizing selective repeat can found here:
This ultimately lets us pick data out of memory given some address.
## Half Adder
For now we'll take two inputs and get 1 output, with a carry-output.
Let's add 2 bits
ab |out
00 |0
01 |1
10 |1
11 |0
What about the carry bit however? What would _it_ look like given the preivous operations?
ab |carryout
00 |0
01 |0
10 |0
11 |1
Before what this implies note that the result of the carryout resembles
## Full Adder
Two inputs, One output, One carry-out, One carry-in
Here we'll add up `a & b`(inputs) and `c` carry-in
cab |output
000 |0
001 |1
010 |1
011 |0
100 |1
101 |0
110 |0
111 |1

Binary file not shown.

BIN
cst363/lab/views-lab.pdf Normal file

Binary file not shown.

54
cst363/lec/lec9.md Normal file
View File

@ -0,0 +1,54 @@
# lec9
## Lab
This lecture has a corresponding lab activity in `lab/`, the instructions are named `views-lab.pdf` and the second one is `contraints-lab.pdf`.
## Views
```
create view newTabelName as select ... from targetTable;
```
This will create a `view` which whenever it is queried will pull data from some base table.
Really the `view` is a kind of "_macro_" which is stored in a `catalog` that normal, non-admin users can use to access a database.
The catalog is saved in a table somewhere in the database.
Think of this catalog like a container(_table_) for the other tables in the database.
### Pros & Cons
Problems:
* Computing the view multiple times can be expensive
* Maintainence
There are two strategies to dealing with the second item: eager and lazy strategies.
1. Eager
* If the target table of some view changes the update the view immediately
2. Lazy
* Don't update the view until it is needed(_queried_)
## Check Contraint
Checks values when they are inserted to validate their legitimacy.
```
create table blah(
id varchar(8) check (id like "%-%"),
);
```
This is how we can avoid accidently putting in null or downright logically incorrect data into a table.
We can also require entries be unique as well.
```
create table blah (
dept_name varchar(20),
...
unique(dept_name)
);
```
_KEEP IN MIND HOWEVER_. With `unique()` if we try to check if a new entry is unique it will always fail with NULL since operations with NULL results in false.
That means we will be able to insert NULL values into the table even if they are not unique.