233 lines
6.9 KiB
Markdown
233 lines
6.9 KiB
Markdown
| Roll Number | 00677611 |
|
||
| ----------- | -------- |
|
||
| ID | CHC119 |
|
||
|
||
# 1 - Linux Bash
|
||
|
||
### 1.1 - If Statements
|
||
|
||

|
||

|
||
|
||
### 1.2 - Processing Variable Number of Arguments with While, Using if
|
||
|
||

|
||

|
||
|
||
# 2 - Linux System Administration
|
||
|
||
#### Setup:
|
||
|
||
- Create **sysadmin** user:
|
||

|
||
- Add **sysadmin** to the **root** group
|
||

|
||
- Create global_aliases.sh and set permissions
|
||

|
||
- Create aliases:
|
||

|
||
- Add source for existing users:
|
||

|
||
- Create users:
|
||

|
||

|
||

|
||
- Create group for Hugh and Ryan
|
||

|
||
- Add Hugh and Ryan to the group
|
||

|
||
- Create shared directory
|
||

|
||
- Set permissions to directory to allow root and sharedaccess to read, write and execute, others can read
|
||

|
||

|
||

|
||
- Set permissions of all folders in /home/ to rwx for exclusively the user that owns it. Other users may not read, write or execute
|
||

|
||

|
||
|
||
#### Testing:
|
||
|
||
##### Aliases
|
||
|
||
- Test **ll** alias:
|
||

|
||
- Test **la** alias:
|
||

|
||
- Test other uses can use alias:
|
||

|
||
|
||
##### Shared Directory:
|
||
|
||
- Both Ryan and Hugh can read and write inside the shared directory.
|
||

|
||
|
||
- Rob can read from the directory:
|
||

|
||
|
||
- Rob cannot write to the directory:
|
||

|
||
|
||
##### Home Directories:
|
||
|
||
- Users cannot access each other's home directories.
|
||

|
||

|
||

|
||
|
||
- However, the owner may access the home directory.
|
||

|
||

|
||
|
||
#### bash_history
|
||
|
||
# CSI Task 1
|
||
|
||
### a)
|
||
|
||

|
||
|
||
#### i)
|
||
|
||
```
|
||
X = (A ∧ B ∧ C) ∨ ( ¬A ∧ B ∧ ¬C) ∨ ( ¬A ∧ ¬B ∧ C)
|
||
```
|
||
|
||
#### ii)
|
||
|
||
```csvtable
|
||
source: 1a.csv
|
||
```
|
||
|
||
### b)
|
||
|
||
Truth Table:
|
||
|
||
```csvtable
|
||
source: 1b.csv
|
||
```
|
||
|
||
Karnaugh Graph:
|
||
|
||
| | | AB | | | |
|
||
| --- | --- | --- | --- | --- | --- |
|
||
| | | 00 | 01 | 11 | 10 |
|
||
| C | 0 | 1 | 0 | 1 | 0 |
|
||
| | 1 | 1 | 0 | 1 | 0 |
|
||
|
||
As we can see from the Karnaugh Graph, the output of C is completely irrelevant.
|
||
|
||
Boolean Expression:
|
||
|
||
```
|
||
OUT = (IN1 ∧ IN2) ∨ ( ¬IN1 ∧ ¬IN2)
|
||
```
|
||
|
||
Logic Circuit:
|
||
|
||

|
||
|
||
# CSI Task 2
|
||
|
||
### a)
|
||
|
||
| Name | George |
|
||
| ------- | ---------------------------------------------------------------------------------------- |
|
||
| Decimal | 71,101,111,114,103,101 |
|
||
| Binary | 1000111,1100101,1101111,1110010,1100111,1100101 |
|
||
| 8N2 | 0(Idle) 1(Start) 01000111 00(Stop) 1(Start) 01100101 00(Stop) 1(Start) 01101111 00(Stop) |
|
||
| | 1(Start) 01110010 00(Stop) 1(Start) 01100111 00(Stop) 1(Start) 01100101 00(Stop) 0(Idle) |
|
||
|
||
- 
|
||
|
||
### b)
|
||
|
||
| Sent | UTF-8 | Binary | UTF-8 | Received |
|
||
| -------- | ----- | ------------ | ----- | -------- |
|
||
| G | 71 | 0100 0111 | 71 | G |
|
||
| e | 101 | 0110 0101 | 101 | e |
|
||
| o | 111 | 0110 1111 | 111 | o |
|
||
| r | 114 | 0111 0010 | 114 | r |
|
||
| g | 103 | 0110 0111 | 103 | g |
|
||
| e | 101 | 0110 0101 | 101 | e |
|
||
| Sum | 601 | 10 0101 1001 | 601 | |
|
||
| Checksum | 89 | | 89 | |
|
||
|
||
601 $mod$ 256 = 89
|
||
or,
|
||
10 0101 1001 AND
|
||
00 1111 1111
|
||
00 0101 1001 = 89
|
||
|
||
Example:
|
||
|
||
| Sent | UTF-8 | Binary | UTF-8 | Received |
|
||
| -------- | ----- | ------------- | ----- | -------- |
|
||
| G | 71 | 0100 0111 | 71 | G |
|
||
| e | 101 | 011**1** 0101 | 117 | u |
|
||
| o | 111 | 0110 11**0**1 | 109 | m |
|
||
| r | 114 | 0111 0010 | 114 | r |
|
||
| g | 103 | 01**0**0 0111 | 71 | G |
|
||
| e | 101 | 0110 0101 | 101 | e |
|
||
| Sum | 601 | 10 0100 0111 | 583 | |
|
||
| Checksum | 89 | | 71 | |
|
||
|
||
Here we can detect an error in transmission, since the checksum differs on each side of the message. A checksum however cannot detect *where* an error occurs, just the fact that it has.
|
||
|
||
### c)
|
||
|
||
$Baud Rate = \frac{Bitrate}{Bits Per Symbol}$
|
||
|
||
$Bit Rate = 2MBps$
|
||
$Bits Per Symbol = 8 data + 1 start + 2 stop = 11 bits$
|
||
|
||
$Baud Rate = \frac{2MBps}{11b} = 0.1818MHz = 181.8kHz$
|
||
|
||
$5F = 5 * \frac{Baud Rate}{2}$
|
||
$5F = 5 * 90.9kHz = 454.5kHz$
|
||
|
||
Required Bandwidth: 454.5kHz
|
||
|
||
# CSI Task 3
|
||
|
||
### a)
|
||
|
||
#### Page Accesses
|
||
|
||
1. 1 2 3 4 5
|
||
2. 2 3 4 1 5
|
||
3. 3 4 1 2 5
|
||
|
||

|
||
|
||
Using the clock algorithm, there are 7 page faults total with this sequence of page accesses.
|
||
|
||
### b)
|
||
|
||
Since A has a runtime of 4 seconds, it is impossible to allocate 4-7 (4, 5, 6, 7 -> 5 processes) second runtime with no conflicts, so I will allocate 4 in a process of my choice.
|
||
|
||
$Response Ratio = \frac{Wait Time + Run Time}{Run Time}$
|
||
|
||
| Process | Runtime | Start Time | Response Ratio |
|
||
| ------- | ------- | ---------- | -------------- |
|
||
| A | 4 | 0 | 1 |
|
||
| B | 5 | 1 | 1.2 |
|
||
| C | 6 | 2 | 1.33 |
|
||
| D | 7 | 3 | 1.43 |
|
||
| E | 4 | 4 | 2 |
|
||
|
||
Process E has the highest Response Ratio, and will be scheduled first.
|
||
Then Process D, Process C, B and finally A.
|
||
|
||
| t (Time) | Complete Process | Start Process |
|
||
| -------- | ---------------- | ------------- |
|
||
| 0 | | A |
|
||
| 4 | A | E |
|
||
| 8 | E | D |
|
||
| 15 | D | C |
|
||
| 21 | C | B |
|
||
| 26 | B | |
|
||
|
||
Since the only available process at t=0 is A, it must still be performed first, regardless of where it sits in the queue.
|
||
E is then available at t=4, when A is completed, allowing the remaining queue to run in descending order of response ratio.
|