Skip to content

10.14 Introduction

Computer Systems

intro-to-computer-science-gtiit-01b-2024.pdf

Hardware

All physical components of the computer

1. Central Processing Unit (CPU) (Processor)

  1. Being responsible of program execution

  2. Executes very elementary instructions

    1. Arithmetic calculations: add, subtract, multiply, etc.
    2. Logical calculations
    3. Basic decisions upon the data
  3. It accesses information outside the CPU through data reading and writing

2. Input/Output components

3. Memory

  1. Primary (Main) memory

    1. Typically called RAM (Random Access Memory)
    2. Volatile (erased each time the computer is shut down)
    3. Relatively expensive (Most computers have relatively “little” RAM)
    4. Very fast
    5. Fixed into the computer
  2. Secondary Memory

    1. Most computers also have a secondary memory.
    2. It is permanent (non-volatile) : it does not need electric current to store data.
    3. In “classic” Hard Disks (HD), data is saved by magnetic means
    4. In Solid State Drives (SSD), data is saved into electronic circuits.
    5. BIG Volumes: They can easily be 500X bigger than primary memory.
    6. Relatively slower than primary memory (but SSDs are much faster than HDs).
  3. Removable Memory Media

    1. Generally, relatively slow
    2. Volume can change between different memories
    3. Non-volatile memory
    4. Main advantage: removable

4. Communication(bus)

Data is transferred between all the components through a bus.

image

Software

The data in the memory

All memory tools (instruments) save data by different means:

  1. Electronically (primary memory, USB drives, memory cards)

  2. Optical (CD, DVD)

  3. Magnetic (HD, Diskette)

In each case, some physical measure can be in two states

  1. High voltage/low voltage; magnetic orientation, etc.

  2. We interpret these two states states as 0 or 1

  3. The memory is, in fact, a large series of binary digits (bits) , each one having value 0 or 1

Bits and Bytes

Memory is organized in basic groups of 8 bits, called a byte.

1 bit can be in one of 2 states

2 bits can be in one of 2*2 = 4 states

3 bits can be in one of 222 = 8 states

4 bits can be in one of 222*2 = 16 states….

One byte (8 bits) can be in one of 2^8 = 256 different states.(00000000 to 11111111)

ASCII use 1 byte to encode the number, symbol and letters.

What can be done with bits?

  • The data in a computer memory is stored binary values

  • Sequences of bits

  • Binary values can be straightforwardly mapped back and forth to numeric (decimal) values
  • What can be done solely with bits, or equivalently, numbers?
  • A lot such that poem and picture

  • We can encode letters from an alphabet, to encode messages in a language as
    sequences of numbers

  • We may also use numbers as representations of colors. Then, a picture or photo may be thought
    of as a sequence of numbers, the number encoding the color of each single pixel in the picture
  • We can also use numbers, e.g., to represent musical notes

Code as numbers

  • Numbers also can be interpreted as commands to be executed (run) by the computer.
  • For example:

  • 0 – read a number from memory.

  • 1 – add 2 numbers.
  • 2 – subtract between 2 numbers.
  • Each CPU has its own particular way of understanding commands. This is the so-called machine language.

Programming in machine language is difficult

  • Every computer architecture has its own machine language. The definition of this language cannot be changed.
  • Machine language is designed for the computer to execute it

  • Writing relatively simple programs in machine language can be highly cumbersome

    • Also reading and understanding such operations is difficult and costly
    • Thus, programmers usually use high level languages.
  • C, Python, Java, …

  • A special tool will translate our high level programs into a machine language, so that the machine can understand it and run it: the compiler.

Translating from high level languages to machine code

  • A compiler is a software tool that automates the translation from a high level programming language to machine code.
  • The C programming language, that we will use in this course, is an example of high level programming language.
  • We will need a C compiler to translate our C programs to machine language, and execute the resulting code.
  • Programs in high level programming languages, like C, are portable:

  • They can be run on different platforms/architectures, as long as we have compilers for such platforms.

  • Compilers also typically improve code efficiency in the translation, to profit from characteristics of the target computer architecture.
  • Compilers are also able to detect syntactic errors in our programs, allowing us to identify programming issues.
  • There exist various alternative C compilers:

  • We will use one of the most notable: GCC.

Compile and execute our first C program

  • JSLinux comes with a few files and directory (when you reset the system they reappear)
  • hello.c is a file that contains the source code of a simple "Hello world" C program
  • See its content by executing cat hello.c
  • To compile and execute, you may use gcc​:

  • gcc hello.c -o hello​ : program in file hello.c is compiled using gcc, into a file named hello

  • ./hello​ : you execute the compiled program (it is necessary to type ./​ at the beginning)