Fundamentals of Computing Systems

Table of Contents

Author: Mrs Ellis

1 Hardware and Software

Learn It: what is hardware and what is software?; what is their relationship?

  • Hardware is all the physical parts of a computer, such as the motherboard, CPU, input and output devices, storage devices.
  • Software is all the written program that make a computer work as intended.
  • Hardware need instructions from software to perform its function while software need hardware to actually carry out intended tasks.

Learn It: Classification of Software: system and application software

  • System software is the software needed to run the computer’s hardware and application software. Examples: operating system, virus software, system monitor software, disk defragmenter etc.
  • Application software is the software that performs one or a set tasks for users. Examples: word processor, spreadsheet, broswer, graphic software etc.

Four Types of System Software

  1. operating system
  2. utility software
  3. libraries
  4. programming language translators

Three Types of Application Software

  1. General Purpose Software: software that can be used for a variety of tasks, such as word processor will allow users to write reports, create a flyer, or menu.
  2. Special Purpose Software: software that performs a specific task, such as payroll processing software is specialised in generating pay slips.
  3. Bespoke software: tailor-made software that only suits a particular organisation or user.

Operating system(OS)

Operating system is a set of programs that manages the operations of the computer. It allows users to use the computer hardware through application software or system software.

OS.jpg

Roles of operating Systems

  • Virtual machine and OS OS creates a virtual machine to allow users to perform tasks without knowing the complexities of managing and communicating with the underline hardware.
  • Multi-tasking OS a CPU can only process one word /instruction at a time. A task may have many instructions. The OS ensures that all tasks’ instructions can be carried out in turn to give the appearance of being processed at the same time.
  • Managing memory
    1. allow multiple programs loaded into RAM without corrupting each other in a multi-tasking OS;
    2. create virtual memory using hard disk if necessary.
  • Managing processes: process scheduling

    A scheduler is a module in OS that ensures all processes can have access to CPU time and the hardware can be used efficiently:

    • Process as many jobs as possible
    • Make maximum use of CPU time
    • Be responsive to the user so they are unaware of a delay to their process
    • Make maximum use of resources such as input-output devices
    • Be fair to all jobs - none left stranded for too long Be able to prioritise jobs
    • Be able to alter priorities according to some rules built into the scheduler
    • Avoid 'deadlock'

    A scheduler may use various scheduling algorithms to achieve its goals:

    Interrupt handling: an interrupt is a signal from hardware or software that needs to be dealt by the OS. Interrupt normally causes the OS to halt its current process and handle the interrupt event. Interrupt examples include software error and hardware failure. Interrupt also used to manage processes:

A hardware interrupt occurs, for example, when an I/O operation is completed such as reading some data into the computer from a hard drive. A software interrupt occurs when an application program terminates or requests certain services from the operating system.

  • Managing backing store

    Backing store is the computer's primary data store. A hard disk is an example of backing store. All programs include OS itself need to be loaded from backing store into RAM in order to work. The OS manages backing store by:

    • creating a file system to allow users to create, delete and move files in the file system
    • read files from the correct storage devices and locations
    • write files to the correct storage devices and locations
  • Managing input and output (I/O) The OS manages peripherals(keyboard, mouse, printer,monitor) by:
    • communicating with input and output devices
    • send and receiving data from input and output devices
  • Providing user interface The OS provide a command line (CLI) and a graphic user interface (GUI)
    • CLI: a text based command prompt interface. Terminal provided in Linux, Windows and MacOS is an example of CLI. CLI requires specific knowledge of commands to work.
    • GUI: windows, icons, menus and pointer (WIMP) to allow navigation and open multiple applications in different windows. Smartphone OS such as iOS and Android uses GUI for user interface.

OS for embedded systems

An embedded system is a computer system with a dedicated function within a larger mechanical or electrical system. example: embedded system in a washing machine, or microwave oven

An embedded system OS needs to:

  • accept inputs (sensors) and generate outputs (typically in real time)
  • have small number of inputs and outputs
  • have minimum user interface
  • have no or minimum permanent storage

Utility programs

Utility programs are programs designed to help configure, optimise, or maintain the computer. Tasks performed by utility programs include:

  • scanning virus
  • disk fragmentation
  • system monitoring
  • file backup and restore
  • firewall
  • encryption
  • compression and decompression

Library programs

Library programs are a collection of pre-written programs to allow other programs to run or to be developed.

  • They are normally written by experts
  • They are well tested and normally bug free

example: Python’s numpy, math, random libraries

Programming language translators (more in details later)

Programming language translators include compilers, interpreters and assemblers. They all translate software into machine code/object code then run by the computer.

Learn It: Classification of Programming Languages

Low-level and High-level Programming Languages

Programming languages can be classified as low-level and high-level programming languages.

Low-level programming languages have a low level of sparations of the code from the underline hardware, are very similar to or based upon the instruction set of the computer. Examples include machine code and assembly code.

High-level programming languages have a high level of separation of code from the actual operations of the computer so programmers can focus on solving the problem. Examples include JAVA, Python, C family languages.

Machine code

Machine code consists of binary digits. A typical machine code instruction consists of operation code (opcode) and the operand.

Opcode represents the instruction to be executed.

Operand represents the value or the address of the value to be operated on.

Fictional examples of machine code operation opcode:

0000 load the value in memory location stored in the operand into the accumulator
0001 store the value in the accumulator in memory location as specified by the operand.
0010 add the value in the accumulator to the value at the address specified by the operand
0011 store the value in the accumulator to address as specified by the operand

So, using the above opcode in a 8-bit instruction, to add two numbers together, the machine code would look like something like this:

0000 0001 load the value stored at address 0001 into accumulator
0010 0010 add the value stored at 0010 to the value in accumulator
0011 0011 store the value in accumulator (the sum) at location 011

Assembly code

After machine code, a second generation programming lanaguage was developed to make the code easier to read. This second generation low-level programming language is called assembly code. It has improved the machine code in two ways:

  1. The opcode was no longer binary digits, a word or string which is easier to remember is used.
  2. The operand was replaced by a decimal or hex number

Each assembly language is specific to a particular computer architecture, in contrast to most high-level programming languages, which are generally portable across multiple architectures, but require interpreting or compiling (more in details later).

The following is an example of some assembly code would look like:

LDA 8 load the contents of location 8 into accumulator
STO 10 store content in accumulator in location 10
ADX 10 add the content of location 10 to the value in the accumulator
PRT 10 print the contents at location specified

To use the above assembly code to add two values, the code would look like so:

LDA 8 Load data at location 8 into accumulator  
ADX 10 add value at location 10 to the value in the accumulator  

Code It

Can you work out how to swap two numbers using the assembly code given before?

Some facts about assembly code

  • Assembly code is hardware dependant. Different processors will have different instruction set and different assembly code.
  • Assembly code can run faster, takes less space and allows bits and bytes level manipulations.
  • Assembly code is still used widely today in systems such as : embedded systems, real-time systems, mobile phone, device drivers.

Learn It: High-level programming languages

Low-level programming languages like machine code and assembly code have some disadvantages:

  1. They are platform dependant
  2. Difficulty to write, requiring hardware specific knowledge (instruction set)
  3. Difficulty to read and debug

In the 1960s, Backus who worked at IBM developed a high-level programming language called FORTRAN (FORmular TRANslation). A example of FORTRAN look like this:

real :: a,pi
print *,'Enter an  angle between 0 and 90'
read *, a
pi = 4.0*atan(1.0)
print *,'the sine of  ',a,' is ',sin(a*pi/180)

As you see, this first high-level language is similar to programming languages like Python in that each statement performing a task and the programmers do not need to be concerned how the task is executed at the machine level and how the data are fetched and stored.

  • High-level programming languages allow programmers to focus on problem solving algorithms not concerned with how computers execute each instruction and how data are fetched and stored.
  • Imperative high-level programming languages: each statement is a command to perform something such as assigning values, calling functions etc. Those commands are executed in sequence to reach a goal.

Other high-level programming languages include JAVA, C++, C#, Visual Basic etc.

Learn It: Programming language translators

  • Three types of programming language translators:
    1. assembler
    2. interpreter
    3. compiler
  • They all translate source code into object code (executable machine code).
  • The translation converts source code into 0s and 1s of the corresponding machine code instructions.
  • Assembler
    • Assembler translate an assembly code into machine code instructions before it can be executed.
    • The assembler takes each assembly code instruction converts it into 0s and 1s of the corresponding machine code instruction.
    • The input to an assembler is called the source code
    • The out put from an assembler is called the object code
  • Compiler
    • A compiler is a program that translates programming languages such as JAVA, C, C++ into executable machine code.
    • A compiler goes through the source code several times to build up necessary information for outputting the object code.
    • The object code can be saved and executed later without the need for a compiler.
  • Interpreter
    • A interpreter checks the entire source code line by line for syntax errors. If only no errors found, it then translates each line into machine code and executes it.
    • Example: Python , Perl, Matlab

Learn It: Compiler or interpreter?

  • advantages of a compiler over an interpreter
    • the object code can be stored on disk and can be run without the need to be compiled. However, if errors found later, corrections need to be made to the source, then recompiling is needed.
    • the object code can be distributed and executed without a compiler present
    • the object code executes faster than interpreted code
    • the object code is more secure since it cannot be easily reverse engineered in order to be read
  • advantages of an interpreter over a complier
    • It is easier to partially test and dengue programs
    • no need for long recompilation whenever an error is found.
  • disadvantages of an interpreter
    • Interpreted programs may run slower as each statement has to be translated into machine code each time it is encountered

Learn It: Intermediate code

  • Intermediate code is the intermediate compiled product between the source code and the machine code.
  • It is more efficient if the compiler (or interpreter) only translates the code to intermediate code, and leaves the translation of the intermedia code to other party.
  • Intermediate code can also be run in a "virtual" machine - this allows the code to run faster than interpreted code.
  • Bytecode
    • Bytecode is the intermediate compiled product between the source code and the machine code.
    • It is executed by a bytecode interpreter.
    • The bytecode may be compiled once as in JAVA or each time a change in the source code is detected as in Python.
    • Bytecode can be interpreted on different platforms, achieving platform independence.
    • Since bytecode in interpreted by a bytecode interpreter, it adds an extra security layer to guard against malicious programs.
    • Programms written in different programming language may be compiled into bytecode of a different programming language and be executed by that language’s byte code interpreter. Jython is an example of compiler for compiling Python into JAVA bytecode.

Research It

Code It