Introduction to Computer Hardware and Operating Systems 101 (CPU/RAM/Kernel)
A computer is an electromechanical device that takes input does processing and produces output.
Inside of a Computer
- Tertiary Storage — added in, like CD, DVD, offline storage system
- Power supply — 12 volts or 5 volts
- Video Card/GPU — connects to the screen, stores information to display on the screen
- Mainboard/Motherboard — physical connectivity for all the devices, if the CPU is the brain, this is the circulatory system.
- CPU — the brain of the computer, all the logic built into it.
- Main Memory/RAM — active all the time, not for long term
- Secondary Storage — permanent storage of the computer
Communication Between the Devices
- Internal communications in a machine are done via a ‘bus’
- A bus is a physical pathway for communication between two or more devices (components)
- Moving back and forth, internal and external
- USB — Universal Serial Bus
- Constantly communicate with the CPU and memory
- The system bus is the main pathway between the CPU and main memory but also carries data to and from input and output (IO) devices
CPU — Central processing unit
- CPU is the brain of the computer, it is a single piece of silicon in the form of a chip, it is the only location where the code is actually executed in the system, and it only runs machine language code.
- Each type of CPU has its own instruction set that can be understood. This set of instructions is represented by a numeric value, When the CPU receives a particular instruction, it performs that task.
- The CPU operates on a ‘fetch-decode-execute’ cycle. Fetch moves the instruction from the main memory into the CPU, and Decode moves in any additional data that might be necessary with that instruction, then Executes that instruction. This process repeats with the next instruction in the sequence. CPU can process millions of instructions per second.
- Inside the CPU, each CPU has a small amount of memory, call ‘register’ which it uses to perform operations and store results like calculations, very small memory in the register.
- The instruction and all the data, have to come from somewhere.
- In order for code to be executed, it has to be in a register built into the CPU.
- Why not just store everything in the register? They are expensive!
- As memory gets faster, it tends to get more expensive.
- All bytes in RAM need an address (unique number), so every byte in the main memory is individually addressable.
- In sleep mode, a small amount of electricity (power) is still on and goes to the RAM to keep it running.
Secondary Storage (2 types)
- hard disk drive — random time — (disc spinning)
- solid state drive — the same amount of time — more efficient
A program that controls the execution of application programs and acts as an interface between the application and computer hardware
- Software like “Windows, iOS, and Linux” manage “the system”
- runs on the same processor as the user’s program code
- does not include applications
Layers of interaction
The user exists at the keyboard, the user uses the application but not interacting operating system, the application interacts with the operating system, and the operating system knows how to use the hardware to provide a solution back to the application.
The Kernel (The core component of the OS)
- responsible for managing system resources
- assists applications with performing work
- Fundamentally, the kernel is the operating system, you have to have the kernel, without the kernel, you can not do anything!
The OS as a Resource Manager
- The most common one is — Memory
- CPU time (who gets the resource)
Back in the Old Days
- the computer ran only one program at a time
- the main operator is a human who does all the job
- Today, we have lots of processing power and lots of resources — enough to run multiple programs at the same time.
- The OS becomes a resource manager — manages the allocation of resources; decides Memory, CPU time, etc; decides which programs can run and when; stop and restart running programs, preemption; time-sharing (not only email but websites and other applications operating at the same time)
Monitoring Running Program
In a modern OS: Many programs can be loaded, all at the same time (activity monitor on iOS). The same program could be loaded multiple times. We need a way to track multiple instances of the same program running on a system — we call it a process.
- A process is: a program in a running state, loaded into the main memory, scheduled
- A process has: access to files, networking connections, and code