Computer Programmes
Miscellaneous notes related to computer programmes, drawing on course material and past learning:
Instructions
- Instructions are encoded as bit patterns in memory, and a CPU is able to fetch, decode and execute them.
- An instruction set architecture specifies how to encode instructions as bit patterns.
- An encoded instruction consists of an opcode portion to specify an action, and an operand portion to tailor the action.
- Instructions are typically either ALU instructions, data instructions or control instructions.
- ALU instructions include arithemetic or bitwise operations, and data stored in registers.
- Data instructions include loading and storing operations, resulting in the movement of data between registers and the main memory unit.
- Control instructions result in the alteration of a pointer value, to point to different blocks of memory that contains other instructions.
- An ISA that tries to minimise the amount of instructions needed for a programme, is called a CISC architecture.
- Intel and AMD are manufacturers that create CISC processors.
- An ISA that tries to minimise the amount of possible instructions, is called a RISC architecture.
- RISC-V specification is an example of a RISC specification.
- ARM (Advanced RISC Machines) is a manufacturer that specifically creates RISC processors.
Programmes
- Programmes are an ordering of instructions.
- Programmes can range from small, simple sequences of instructions, to large, complex, cyclic graphs with conditional branching.
- Efficient programmes make use of algorithms and data structures to save time and space in memory.
- The execution of a programme is called a process.
- A programme counter is a pointer value that indicates which instruction to execute next in a process.
- Multiple processes can execute simultaneously on a computer with a parallel computing architecture.
- A combination of programmes and data is called software.
Operating Systems
- An operating system is a type of software designed to provide functionality to a computer's hardware.
- Examples of operating systems include: Windows 11, MacOS Ventura, and Ubuntu (which uses a Linux kernel).
- The main programme of an operating system is called the kernel.
- The kernel is stored in non-volatile memory for long term storage, and is loaded into main memory upon computer startup by instruction of a bootloader programme that's immediately accessible to the CPU.
- Once the kernel has been loaded, it governs the execution of all other programmes.
- The kernel manages resource access too, such as access to memory, peripherals, and processing units by processes.
- The kernel also provides common services to processes such as the displaying of content in windows, and the organisation of files using directories.
- When a computer is turned off, the kernel is erased from main memory.