Upgrade to Pro — share decks privately, control downloads, hide ads and more …

M250 Unit 1 Subsection 2 - Fundamental hardware...

Avatar for Matt Matt
January 01, 2020

M250 Unit 1 Subsection 2 - Fundamental hardware and software concepts (1)

During my study of M250 I made extensive notes. I hope they can be of use to you.

Avatar for Matt

Matt

January 01, 2020
Tweet

More Decks by Matt

Other Decks in Education

Transcript

  1. Quick note: Every unit’s subsection 1 is just an introduction.

    The ideas found within the introduction are always explained in later subsections. So we essentially start every unit at subsection 2.
  2. The Operating System (OS) • The Operating System (OS) is

    a piece of software that runs on top of the computer’s hardware. • The OS usually comes pre-installed when you buy a computer.
  3. The OS has many functions. The OS: • Allocates and

    maintains the memory for each programme. • Allows basic system operations to take place such as input/output. • Receives input from peripheral devices (i.e. speakers, keyboard, mouse). • Acts as a ‘buffer’ between the user and a programme. The user doesn’t need to tell a programme to do something, they just need to tell the OS which then controls the programme to do that thing. • Provides a user-interface. The windows and buttons that we see and interact with are a part of this interface.
  4. How programmes execute on a computer There are three types

    of code to talk about: - Source code - Machine code - Bytecode
  5. Source code The source code is the text that we

    type when writing in a programming language such as Java. While it has to follow the correct syntax, the important thing to note about source code is that it is understandable to a user. For example, the code: System.out.println(“Hello World”); is a piece of source code. We can see it and, without needing to execute it, we can make an educated guess to its function: it prints a line of text saying “Hello world”.
  6. Machine code Machine code is read by the hardware of

    a computer. It is a programming language that the computer’s hardware can interpret. Although a user could learn it (and indeed this was necessary at one point) it is difficult, unintuitive, and time-consuming. - Machine code is known as a low-level programming language. - Java is one of many high-level programming languages. A high-level programming language abstracts away from the complexity of a low-level language
  7. So when we write source code (in a high-level language)

    this needs to be converted to machine code (a low-level language) so that the instructions we’ve written can be executed. This translation is done by software called a compiler. So the user writes some source code, the compiler converts this to machine code, and then this is executed. Seems okay, right?
  8. There is a problem with this simple system. The problem

    is that different computers have different machine code instruction sets. That is, they read machine code differently. So source code that is translated directly into machine code would not be understood if sent to a different computer. This limits the portability of code.
  9. Java, and other high-level programming languages, use a better method

    of code compilation that gets around this problem. To understand this method we first need to talk about the virtual machine.
  10. The Java Virtual Machine On top of the OS is

    a piece of software called the virtual machine. A virtual machine mimics hardware, and has its own instruction sets just like hardware, but is in fact software. The Java Virtual Machine (JVM) converts source code into bytecode. We can think of bytecode as the machine code of the JVM.
  11. So how do Java programmes execute on a computer? We

    can think of this process as consisting of three stages: 1] The user writes the source code. 2] The JVM compiles the source code into bytecode. 3] The bytecode is compiled into machine code which then executes.
  12. The advantage of using this method is that the bytecode

    can be shared between different computer systems. As long as each computer system has the same JVM installed, the bytecode can be translated into machine code separately on different computers, and will work the same.