- Richard Feynman -
Computer introduction
Contents
Computer introduction
Meta information about this chapter
Created | Reviewed | Ready | |
---|---|---|---|
Exercises | ok | ok | no |
Solutions | ok | no | no |
Videos | ok | ok | ok |
Expand using link to the right to see the full content.
Books this chapter belongs to
Introduction
The concepts here will give you a very basic introduction to the computer and the hardware components it consist of.
Memory is used in all programs, no matter what programming language. This lecture shows the similarities between how we humans think and how computers “think”. This presentation also gives the needed background for understanding variables, which is an important concept in languages such as Java and C.
You will get a basic introduction to the OS (operating system) of a computer.
When developing software files and directories are used all the time, for storing software code in a file which in turn is located in a directory.
Understanding the file system at a basic level is important to understand the build process of programming languages, especially when developing C programs.
Knowing what a program is and what file types can be executed on an OS and on a computer with no OS is important to understand how a program can be developed, built and executed. It is not possible (right now) to execute a Java program on an Arduino even if we can compile it to a binary (as opposed to the normal Java byte code). Why is that?
Purpose
The concepts are important to understand when programming in C and when getting
To get a good understanding of variables and computer programs in general a brief understanding of the computer’s memory is needed.
The concepts are important to understand when programming since programs use the OS (operating system) to manage the underlying hardware. Getting a basic understanding of the services offered to the programmer by the OS is a foundation for understanding the role and surrounding environment for a program, as well as giving an understanding the role of the programming language C.
Giving the student knowledge about with file system.
Programs, audio, photo, . . . everything is stored in files. So an understanding of files and file system is crucial when programming.
These lectures give the student a clearer picture of how programs, processes and source code relate to each other.
Goal
Provide a basic understanding of a computer’s hardware and a basic understanding of how the computer’s hardware is abstracted and offered by the OS to the programmer via a programming language. This will serve as a foundation for the coming lectures.
The student shall:
- be able to explain what computer memory is and hos it is used/addressed.
- be familiar and be able to create directories
- be familiar and be able to able to find files in a file system
- understand what a file system is
- have an understanding of how programs and processes relate to source code, OS and files.
- understand the role of and the services offered by an OS
Concepts
- CPU
- [#Section:Memory]
- Peripheral
- bios
- hard-disk
- serial-interface
- usb
- mouse
- keyboard
- network
- #Memory
- Stack
- Heap
- kernel
- filesystem
- rtos
- embedded-os
- network
- OS
- operating-system
- file
- text-file
- binary-file
- object-file
- directory
- Source Code
- filesystem
- software-module
- program
- virtual-machine
- execution
- interpreter
- byte-code
- process
- script
- Source code
Instructions to the teacher
Common problems
Files and directories seems both easy and neglected in software development literature. Based on our experience we put emphasis on these concepts since they ease up explaining the build process as well as serve as a foundation for understanding packages (in Java).
All videos
All videos in this chapter:
See below for individual links to the videos.
Hardware
Description
Computer hardware (or simply hardware in computing contexts) is the collection of physical elements that constitutes a computer system. Computer hardware is the physical parts or components of a computer, such as the monitor, mouse, keyboard, computer data storage, hard disk drive (HDD), graphic cards, sound cards, memory (RAM), motherboard, and so on, all of which are tangible physical objects. By contrast, software is instructions that can be stored and run by hardware. Hardware article on Wikipedia
Videos
- Hardware (eng) (sv) (download presentation)
Exercises
- What is the hardware used to store information temporarily (until the power goes off) called?
- What is the hardware used to store information permanently (even after the power goes off) called?
- What is the hardware that functions rather much like the brain in the computer? I. e what part of the computer is the one who does the "thinking"?
- Give examples of hardware that can be used to communicate with a computer.
- What is the difference between software and hardware?
- What is the memory in a computer used for?
- When storing a value in memory the computer puts that value in a certain place, called an address. Instead of you and/or your program remembering the address you can name this memory, e g `nr-of-students`. What is such a named memory called?
Solutions
Expand using link to the right to see the full content.
- RAM or memory.
- Disk. There are several different kinds of disks, e g hard disk. Sometimes this is referred to as persistent memory.
- CPU - Central Processing Unit.
- The list will be long if we tried to list them all, so we’ll give
- some examples:
- screen/monitor/tv
- keyboard and mouse
- joystick and game pad
- gesture detection hardware
- voice recognition hardware
- ...
- Software are sequences of instructions performed by some kind of hardware, in our case typically the CPU in the computer. The software is not a physical item, although it is stored on some kind of storage media. Hardware is some kind of physical device that can perform some task(s) in relation to the computer. The hardware can be instructed using programs or it can be “hard wired”.
- The memory is used to store information/data.
- Variable
Links
Von Neumann architecture (wikipedia)
Random-access memory (wikipedia)
Filetype
Description
Videos
Exercises
- There are two main catergories of file type, text files and binary files. Explain what they are and give examples of each.
- Together with these exercises you have a source code file src/Testing.java`). Open this file using different programs, e g
- firefox, chrome or some other browser
- emacs, notepad, edit or some other text editor
- vlc or some other media player
- Together with these exercises you have a presentation in video format. Open this file using different programs, e g
- firefox, chrome or some other browser
- emacs, notepad, edit or some other text editor
- vlc or some other media player
- Together with these exercises you have a document stored in various different formats. Open these documents (one by one) in
- firefox, chrome or some other browser
- emacs, notepad, edit or some other text editor
- vlc or some other media player
Solutions
Expand using link to the right to see the full content.
- Text files are files containing text only. Binary files can contain anything.
- Text files:
- HTML files
- software source code
- XML files
- Binary files:
- audio files (ogg, mp3, ...)
- video files (ogv, avi, mp4 ...)
- Text files:
Links
File system
Description
Videos
Exercises
Some notes on typography: To show that a command is entered interactively via the terminal window, the command line is prefixed with a dollar sign "$". The commands you should enter follows the "$". In other words, you should not enter the "$" itself, it is just there to show that the command is entered into a terminal window!
- Open the computer's shell in a terminal (e.g. cygwin).
- Find out where in the file system you're in. This can be done in several ways. You can, for example, look at the prompt:
username:/home/adam$
or using ~ to mean "home directory" :username:~$
- You're in your "[HOME]" folder. HOME is nothing but a directory simply called HOME. Each (normal) user has a HOME directory. Nowadays the home directory contains directories such as [Desktop directory], [Documents directory], [Photos directory] etc.
- You can also run a command in the shell, e g pwd:
$ pwd
- Your location (where you stand) is called working directory or "current directory". The command pwd is an abbreviation for "print name of current/working directory".
- Create a new directory using mkdir:
$ mkdir new-catalog
- Make sure you can see the directory:
$ ls new-catalog
- Check which files and directories exist in the current directory. This can be accomplished simply by entering:
-
$ ls
-
- Change directory to the newly created directory (new-catalog):
-
$ cd new-catalog
- Verify that you have changed directory:
-
$ pwd
-
- Check if there are any files in this directory:
-
$ ls
-
- Create a file in the new directory using your favorite application for creating text files (an editor of some sort). Save the file (in the newly created directory) and exit the editor. Return to the shell/terminal and list all files in the newly created directory again. Can you see the new textfile listed? If not, you have made some error while saving the text file!
- To list all files, enter:
-
$ ls
- and verify that you see the file in the list.
- Go back to the directory you originally were located in (one directory "up" from the newly created directory):
-
$ cd ..
-
- Find out what directory you are now located in. It should be "above" the newly created directory.
$ pwd
- Delete the text file you created in the new directory using the rm command:
-
$ rm new-catalog/THE_FILE_NAME_YOU_CHOSE
-
- Verify that the file is now gone:
-
$ ls new-catalog
-
- Delete the new directory. N.B.! The syntax below will only work if you are located in the directory "above" the directory to be removed. That is, if you are located in the directory where you were located when you created the new directory. To remove a directory (and all of its contents) use the rm command with the -r flag. Or you may use the rmdir command to remove an empty directory.
- (alteratively, you may use the
$ rm -r new-catalog
command)rmdir
-
- Verify that the directory is gone:
-
$ ls new-catalog
- The shell should reply: "No such file or directory"
-
- Launch an application from the command line. For instance, launch notepad or TextEdit (or some other application). Find out how to do this using any search engine you'd like. Hint for search phrases to enter into the search engine:
- open text editor from command line cygwin
Solutions
There are no solutions for these exercises.
Links
Working with the file-system (The Linux Documentation Project)
OS
Description
"An operating system (OS) is system software that manages computer hardware and software resources and provides common services for computer programs. The operating system is a component of the system software in a computer system. Application programs usually require an operating system to function.
Time-sharing operating systems schedule tasks for efficient use of the system and may also include accounting software for cost allocation of processor time, mass storage, printing, and other resources.
For hardware functions such as input and output and memory allocation, the operating system acts as an intermediary between programs and the computer hardware,[1][2] although the application code is usually executed directly by the hardware and frequently makes system calls to an OS function or is interrupted by it. Operating systems are found on many devices that contain a computer – from cellular phones and video game consoles to web servers and supercomputers.
Examples of popular desktop operating systems include Apple OS X, Linux and its variants, and Microsoft Windows. So-called mobile operating systems include Android and iOS. Other classes of operating systems, such as real-time (RTOS), also exist."
Operating System (wikipedia)
Videos
Exercises
- Give examples of how different computers communicate with each other.
- If you want to send an ordinary mail you specify the recipient and the address. How do you specify the recipient of an email? Explain the parts of the address.
- Let's assume you want to go to a website, e g www.gnu.org. From where does your computer get data (or information) when you tell the browser to open up that address?
- In (3) your computer connects to another computer to get the information. That computer is connected using an address different from www.gnu.org. How is www.gnu.org translated to a so called IP address?
- Start a shell (or command prompt).
- Find out what date it is by using the shell
- Print the value of the PATH variable. This is done in different ways depending on the underlying operating system.
- Explain in your own words what is printed out.
- Assign the PATH variable the value 12. This really is not a very clever thing to do.
- Print the value of the PATH variable and explain in your own words what is printed out.
- Print the value of the NOTEXIST variable. Explain in your own words what is printed out.
- Assign the NOTEXIST variable the value 42. Print the value of the NOTEXIST variable and explain in your own words what is printed out.
Solutions
Expand using link to the right to see the full content.
- Using (IP) network cards, bluetooth, serial cable, pidgeons leds.... Most common way to communicate is to use network cards. The internet is loads of computers connected via network cards.
- Let's assume you want to send an email to one of the authors of these exercises, Henrik Sandklef. His address is sandklef@chalmers.se. There are two parts in this email address separated by the @ sign. The second part chalmers.se is the domain name, typically an organisation or company name. The first part sandklef is the recipient at the specified organsiation. So when you're sending the email the email is received by a computer at chalmers.se and by that computer is stored in sandklef's INBOX.
- Your computer opens a network connection to the computer at www.gu.se and gets the information from that.
- The address www.gu.se is translated using Domain Names Servers to an IP address (4 numbers separated with three dots).
- This is done in ways that differ between OS:es. Go back to the videos on bash and cygwin for more information.
- Type the following command
-
date
-
- Type the following command
-
echo $PATH
-
- The various directories where the operating system (more specifically the shell) will look for program are listed.
- Type the following command
-
PATH=12
-
- 12 is printed out since the value of the PATH variable now has been set to 12
-
echo $NOTEXIST
-
- Most likely this variable has no value assigned so nothing is printed.
- Type the following command
NOTEXIST=42
- 42 is printed out since the value of the NOTEXIST variable now has been set to 42.
Links
Program
Description
Videos
Exercises
- What is a program? Give some examples of programs.
- What is a process?
- Give two examples of how a program can be started by a user?
- Does a program have to have a GUI (graphical user interface)?
- What do you think happens when starting chrome (a browser) from a shell the following way: `chrome http://www.gnu.org`
- What are the argument(s) supplied to a program (see previous exercise) on the command line called?
Solutions
Expand using link to the right to see the full content.
- A program is a sequence of instructions that a computer with an operating system can execute.
- Examples: chrome, firefox, thunderbird
- A process is an executing instance of a program?
- You can start programs:
- from the shell
- from a menu system (e.g. start menu)
- by clicking a link
- ... and probably several more ways
- No. Many program have no graphical user interface. These programs are often text based in its communication with the user or system.
- Chrome starts up and loads the website http://www.gu.se
- There are different names for these arguments:
- Command line arguments
- Command line option
- Program options
- In this course we will use the first (Command line arguments).