From d2601a83106f97a447c5fac82717bfe8d96cff1c Mon Sep 17 00:00:00 2001 From: tactonbishop Date: Mon, 8 Aug 2022 15:00:04 +0100 Subject: [PATCH] Last Sync: 2022-08-08 15:00:04 --- Databases/MongoDB/Introduction.md | 29 +++++++++++++++++++++-------- Hardware/Bus.md | 4 +++- Hardware/CPU/CPU_architecture.md | 19 ------------------- Hardware/CPU/Introduction.md | 9 +++++++++ 4 files changed, 33 insertions(+), 28 deletions(-) diff --git a/Databases/MongoDB/Introduction.md b/Databases/MongoDB/Introduction.md index 41cbbfc..747e8d3 100644 --- a/Databases/MongoDB/Introduction.md +++ b/Databases/MongoDB/Introduction.md @@ -22,13 +22,23 @@ Then start the Mongo daemon ```bash mongod ``` -This will run continuously in the terminal and should say somewhere that it is waiting for connections on port 27017. This command must be used before you run any backend that interacts with the Mongo database. +This will run continuously in the terminal and should say somewhere that it is waiting for connections on port `27017`. This command must be executed before you run any backend that interacts with the Mongo database. ### MongoDB Compass -_Compass_ is a graphical interface for viewing and interacting with the data in your Mongo database. It will automatically load to the default Mongo port: 27017. +_Compass_ is a graphical interface for viewing and interacting with the data in your Mongo database. It will automatically load to the default Mongo port: `27017`. ![](/img/mongo-compass.png) ### Arch Linux troublshooting +Most times any problems will be a result of a Mongo process that is already running. Resolve with: + +```bash +# Kill running Mongo process... +# Identify PID +sudo lsof -iTCP -sTCP:LISTEN -n -P +sudo kill [pid] +``` +Otherwise try the below. + ```bash # Check that the systemd service is runnign for Mongo sudo systemctl status mongodb @@ -39,16 +49,16 @@ sudo systemctl start --now mongodb # If issues with Mongo daemon... # Remove the current socket -rm mongodb-27017.sock - -# Kill running Mongo process... -# Identify PID -sudo lsof -iTCP -sTCP:LISTEN -n -P -sudo kill [pid] +rm /tmp/mongodb-27017.sock ``` +## Databases, collections, documents + +Although Mongo is not a relational database it has a structure that we can understand in relation to that paradigm. A **database** is obviously the overall structure. It comprises **collections** which are organised sets of data that are analagous to [tables](/Databases/Relational_database_architecture.md#table) in RDBs. Within each collection are a series of **documents** which we can think of as being equivalent to [rows](/Databases/Relational_database_architecture.md) in RDB table: units that comprise the collection. + ## Mongoose +### Connecting to our database Now that we have installed and configured MongoDB, we need to connect from it via Node.js.Mongoose is a simple API for interacting with a Mongo database via Node. With this installed we can connect to a database. We don't have any Mongo databases yet beyond the defaults but the following Mongoose connection logic will create and connect to a new database called `playground`: @@ -59,3 +69,6 @@ mongoose .then(() => console.log("Connected to MongoDB")) .catch((err) => console.error(err)); ``` +### Creating collections and documents + +In order start adding collections and documents to our database, we use Mongoose's schema structure. (This is specific to the Mongoose wrapper and is not a structure that is a part of Mongo in general.) \ No newline at end of file diff --git a/Hardware/Bus.md b/Hardware/Bus.md index c7ae2aa..4e582d9 100644 --- a/Hardware/Bus.md +++ b/Hardware/Bus.md @@ -43,8 +43,10 @@ Serial Transmission is the type of transmission in which a single communication Latency means _delay_: the delay from the time the data is requested until the time it arrives. In the context of a microprocesser and buses a key locus of latency would be between the time a request takes to travel accross the system bus from the CPU to the memory. -// TODO: Add explanation of bandwidth in the context of Hertz +### Bandwidth +In general, bandwidth is a measure of the capacity for a communications channel to transmit data. A bus is a channel between two components thus we can talk about the bandwidth of buses. The speed and efficiency of a bus is a function of its bandwidth, although other factors such as its length and proximity to the source and receiver are also important. +Bandwidth can be calculated in terms of how many bits can be transferred per second. The wider the bus, the more bits that can be transferred. If we have a bus that can run at 66MHz and transfer 64 bits, 64 bits is 8Mb thus the bandwidth is 8 x 66 = 528Mb. ## Standards The mode of transmission is used to distinguish the different bus standards. diff --git a/Hardware/CPU/CPU_architecture.md b/Hardware/CPU/CPU_architecture.md index 0a2da7a..5b2702d 100644 --- a/Hardware/CPU/CPU_architecture.md +++ b/Hardware/CPU/CPU_architecture.md @@ -55,25 +55,6 @@ The CPU's [controller](/Hardware/Chipset_and_controllers.md). It takes the instr ## Fetch, decode, execute -*Fetch, decode, execute* is the operating cycle of the CPU. We will run through how this works with reference to the CPU architecture. - -### Fetch - -1. The Program Counter register needs to keep track and sequence the different instructions that the CPU will work on. The first place it will look for an instruction is at the DRAM address `0000`, equivalent to 0 in the Program Counter register: the starting point. This is address therefore copied to the Memory Address Register for future reference. -2. This memory-storing event constitutes an instruction so it is copied to the Instruction Register. -3. As the first instruction has been fetched, the system reaches the end of the first cycle. Thus the Program counter increments by 1 to log this. -4. The next fetch cycle begins. - -### Decode - -1. Now that the instruction is fetched and stored in the RAM it needs to be decoded. It is therefore sent from the RAM to the Control Unit of the CPU. There are two parts to the instruction: - 1. The operation code ("op code"): the command that the computer will carry out. - 2. The operand: an address in RAM where the data will be read and written to as part of the execution -2. The Control Unit converts the operation code and operand into an instruction that is fed to the next stage in the cycle: execution - -### Execute - -Now the command will be executed. The operand is copied to the Memory Address Register and then passed to the Memory Data Register and the command is carried out by the ALU. ## The system clock diff --git a/Hardware/CPU/Introduction.md b/Hardware/CPU/Introduction.md index e69de29..3222f45 100644 --- a/Hardware/CPU/Introduction.md +++ b/Hardware/CPU/Introduction.md @@ -0,0 +1,9 @@ +--- +tags: + - Hardware + - cpu +--- + +# CPU: Introduction + +At the core of a computer sits the Central Processing Unit. This is the assembly of chips that execute all computation. Instructions are passed to the CPU along the data bus part of the system bus from the memory. The [kernel](/Operating_Systems/The_Kernel.md), also residing in memory sequences and schedules the sending of data to the CPU and manages requests from the CPU for data in memory.