# A-level Computing/AQA/Paper 2/Fundamentals of computer systems/Hardware and software
## Hardware and software

* Specification coverage
* 3.6.1 - Hardware and software

## Hardware

Computer hardware is the physical components of the computer. It is important to distinguish between the internal components, which are the processing and storage devices, and external components, normally referred to as peripherals.
* External components (peripherals): The external components of hardware are the parts that you can touch, for example the monitor mouse, keyboard and printer. The external components are used either to get data into or out of the system. Consequently, they are referred to as input and output (I/O) devices.
* Internal components (processing and storage): the internal hardware components are housed within the casing of the computer and include the processor, the hard disk, memory chips, sound cards, graphics cards and the circuitry required to connect all of these devices to each other and to the I/O devices.

## Software

Software is the general term used to describe all of the programs that we run on our computers. These programs contain instructions that the processor will carry out in order to complete various tasks. This covers an enormous range of possibilities from standard applications, such as word processors, spreadsheets and databases, to more specific applications, such as web-authoring software and games. It also includes programs that the computer needs in order to manage all of its resources, such as file management and virus-checking software.
Application software refers to all of the programs that the user uses in order to complete a particular task. In effect, it is what users use their computers for.
System software covers a range of programs that are concerned with the more technical aspects of setting up and running the computer. There are four main types:
* Utility programs
* Library programs
* Translators
* Operating system software
Utility programs covers software that is written to carry out certain housekeeping tasks on your computer. Utility programs are often made available free downloads and are designed to enhance the use of your computer and programs though your computer will still work without them. A common example of a utility program is compression software.
Library programs are similar to utility program in that they are written to carry out common tasks. The word library indicates that there will be a number of software tools available to the users of the system. Whereas some utility programs are non-essential, library programs tend to be critical for the applications for which they were built, for example Dynamically Linked Library (DLL) files, which contain code, data and resources.

## Translators

Translators are software used by programmers to convert program from one language to another. There are three types: compilers, assemblers and interpreters.
In order to write software, programmers use programming languages which allow them to write code in a way that is user-friendly for the programmer. However, the processor will not understand the programmers' code, so it has to be translated into machine code, that is, 0s and 1s. Compilers, assemblers and interpreters are used to carry out this translation process.

### Benefits and Drawbacks of Interpreters and Compilers

Benefits of an Interpreter
* You don't need to compile the whole program to run sections of the code.
* Interpretation happens each time the code is executed, so the program can be run on processors with different instruction sets.
* It is useful for finding bugs when developing code
Drawbacks of an Interpreter
* Time taken to execute a program can be long. This is partly because if you repeat the same section of code over and over again, you need to translate each time.
* To run a program, the computer must have an interpreter installed.
* To distribute the code, you need to distribute the source code
Benefits of a compiler
* Once compiled, you no longer need a compiler or the source code
* When distributing your program, the source code is difficult to work out
Drawbacks of a Compiler
* Compiled code only works on computers using the same instruction set
* One small change in code leads to a need to recompile

### Bytecode

Bytecode is an intermediate code (i.e. it is between source code and object code). Source code is translated in to bytecode, which can be run on a virtual machine (such as the Java Virtual Machine). A virtual machine translates bytecode into the appropriate instruction code.

## Operating system software

An operating system is a collection of software designed to act as an interface between the user and the computer manages the overall operation of the computer. It links together the hardware, the applications and the user, but hides the true complexity of the computer from the user and other software - a so - called virtual machine. Operating system is not referred to as a virtual machine. This is misleading.
Common tasks carried out by the operating system include:
* provide an interface between the computer and user;
* to manage devices/files/memory;
* to provide a virtual machine;
* to provide a software platform on which other programs can run// to run application software;
* to hide the complexity of the hardware from the user.

### Resource management

In a computer with only one processor, only one program can be running at any one moment in time. In order to allow more than one program to appear to run simultaneously, the operating system has to allocate access to the processor and other resources such as peripherals and memory.
One of the main tasks that an operating system has to do is to make sure that all these allocations make the best possible use of available resources. Usually the most heavily used resource in a computer is the processor. The process of allocating access to the processor and other resources is called scheduling.
The simplest way that an operating system can schedule access to the processor is to allocate each task a time slice. This means that each task is given an equal amount of processor time. This process of passing access to the processor from one tasks to the next is also known as 'round-robin' scheduling.
Accessing some devices is a relatively slow process compared to the speed at which the processor can handle requests. Rather than wait for each process to end before it can continue, the OS can effectively create a queue of commands that are waiting for the device and then handle each request in sequence or based on priority.

### Memory management

The OS stores details of all the unallocated locations in a section of memory known as the heap. When an application needs some memory, this is allocated from the heap, and once an application has finished with a memory location or perhaps an application is closed, the now unneeded memory locations are returned to the heap. The OS controls the use of main memory by creating a memory map which shows which blocks of memory have been allocated to each task. In this way an operating system can control more than one task in the RAM at any one time.

#### Virtual Memory

If applications need more memory than a computer has, then the OS will sometimes use a section of secondary storage to mimic RAM. This is called virtual memory.

### File management

The OS is responsible for managing the files stored, and the folders that they are stored in. This provides the user an easy understandable way to manage their files, which hides the complexity of how files are stored on the hard drive.

### Input/Output Management

The OS is responsible for dealing with devices for input (keyboards, mouse) as well as output (allocating print jobs, screen output).

## Summary

* A computer system is made up of hardware and software.
* Hardware is usually classified in terms of internal and external components.
* System software includes the operating system, library and utility programs.
* Compilers, interpreters and assemblers are programs that convert high-level programming languages into executable instructions.
* The operating system plays a critical role in managing resources.
* Exercises
* A computer system consists of hardware and software. What is meant by hardware and software?
* Answer:
* Hardware - the electrical/ physical components/parts (electronic circuits) of the computer.
* Software - programs (sequences of instructions) which run on the hardware/computer.
* Peripherals can be classified as input, output or input/output (I/O) devices. Explain what a peripheral is.
* Answer:
* One of the following:
* A (hardware) device that is not part of the CPU;
* An external (hardware) device;
* Not built into/part of (main) computer (system) // Outside computer.
* System software performs the tasks needed to operate the hardware. The operating system and library programs are system software.
* State one role of the operating system and one purpose of library programs..
* Answer:
* Operating system:
* provide an interface between the computer and user;
* to manage devices/files/memory;
* to provide a virtual machine;
* to provide a software platform on which other programs can run// to run application software;
* to hide the complexity of the hardware from the user.
* Library programs:
* to allow sharing of run-time code across programs;
* to save memory as routines are only loaded when needed;
* to provide access to procedures/functions when writing a program;
* to reduce amount of programming required // time taken to write program.
* What type of program translator is used to translate assembly language into machine code?
* Answer:
* Assembler
* The RobotC program that has been copied to the robot can be executed by the built-in interpreter. How does a high level language interpreter work?
* Answer:
* analyses statement by statement each line of source code;
* runs/translates/executes line by line;
* calls routines to carry out each instruction/statement.