Computer introduction

From Juneday education
Jump to: navigation, search

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

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

  1. Hardware (eng) (sv) (download presentation)

Exercises

  1. What is the hardware used to store information temporarily (until the power goes off) called?
  2. What is the hardware used to store information permanently (even after the power goes off) called?
  3. 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"?
  4. Give examples of hardware that can be used to communicate with a computer.
  5. What is the difference between software and hardware?
  6. What is the memory in a computer used for?
  7. 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.


  1. RAM or memory.
  2. Disk. There are several different kinds of disks, e g hard disk. Sometimes this is referred to as persistent memory.
  3. CPU - Central Processing Unit.
  4. The list will be long if we tried to list them all, so we’ll give
    some examples:
    1. screen/monitor/tv
    2. keyboard and mouse
    3. joystick and game pad
    4. gesture detection hardware
    5. voice recognition hardware
    6. ...
  5. 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”.
  6. The memory is used to store information/data.
  7. Variable

Links

Hardware article on Wikipedia

Von Neumann architecture (wikipedia)

Random-access memory (wikipedia)

Filetype

Description

Videos

  1. File Type (eng) (sv) (download presentation)

Exercises

  1. There are two main catergories of file type, text files and binary files. Explain what they are and give examples of each.
  2. Together with these exercises you have a source code file src/Testing.java`). Open this file using different programs, e g
    1. firefox, chrome or some other browser
    2. emacs, notepad, edit or some other text editor
    3. vlc or some other media player
  3. Together with these exercises you have a presentation in video format. Open this file using different programs, e g
    1. firefox, chrome or some other browser
    2. emacs, notepad, edit or some other text editor
    3. vlc or some other media player
  4. Together with these exercises you have a document stored in various different formats. Open these documents (one by one) in
    1. firefox, chrome or some other browser
    2. emacs, notepad, edit or some other text editor
    3. vlc or some other media player

Solutions

Expand using link to the right to see the full content.

  1. Text files are files containing text only. Binary files can contain anything.
    1. Text files:
      1. HTML files
      2. software source code
      3. XML files
    2. Binary files:
      1. audio files (ogg, mp3, ...)
      2. video files (ogv, avi, mp4 ...)

Links

File system

Description

Videos

  1. File system (eng) (sv) (download presentation)

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!

  1. Open the computer's shell in a terminal (e.g. cygwin).
  2. 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.
  3. You can also run a command in the shell, e g pwd:
    $ pwd
  4. 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".
  5. Create a new directory using mkdir:
    $ mkdir new-catalog
    
  6. Make sure you can see the directory:
    $ ls new-catalog
    
  7. Check which files and directories exist in the current directory. This can be accomplished simply by entering:
    $ ls
    
  8. Change directory to the newly created directory (new-catalog):
    $ cd new-catalog
    
    Verify that you have changed directory:
    $ pwd
    
  9. Check if there are any files in this directory:
    $ ls
    
  10. 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.
  11. Go back to the directory you originally were located in (one directory "up" from the newly created directory):
    $ cd ..
    
  12. Find out what directory you are now located in. It should be "above" the newly created directory.
    $ pwd
    
  13. Delete the text file you created in the new directory using the rm command:
    $ rm new-catalog/THE_FILE_NAME_YOU_CHOSE
    
  14. Verify that the file is now gone:
    $ ls new-catalog
    
  15. 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.
    $ rm -r new-catalog
    
    (alteratively, you may use the
    rmdir
    
    command)
  16. Verify that the directory is gone:
    $ ls new-catalog
    
    The shell should reply: "No such file or directory"
  17. 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

File system (wikipedia)

File (wikipeda)

Directory (wikipedia)

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

  1. OS (eng) (sv) (download presentation)

Exercises

  1. Give examples of how different computers communicate with each other.
  2. 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.
  3. 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?
  4. 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?
  5. Start a shell (or command prompt).
  6. Find out what date it is by using the shell
  7. Print the value of the PATH variable. This is done in different ways depending on the underlying operating system.
  8. Explain in your own words what is printed out.
  9. Assign the PATH variable the value 12. This really is not a very clever thing to do.
  10. Print the value of the PATH variable and explain in your own words what is printed out.
  11. Print the value of the NOTEXIST variable. Explain in your own words what is printed out.
  12. 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.

  1. 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.
  2. 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.
  3. Your computer opens a network connection to the computer at www.gu.se and gets the information from that.
  4. The address www.gu.se is translated using Domain Names Servers to an IP address (4 numbers separated with three dots).
  5. This is done in ways that differ between OS:es. Go back to the videos on bash and cygwin for more information.
  6. Type the following command
      date
    
  7. Type the following command
      echo $PATH
    
  8. The various directories where the operating system (more specifically the shell) will look for program are listed.
  9. Type the following command
      PATH=12
    
  10. 12 is printed out since the value of the PATH variable now has been set to 12
      echo $NOTEXIST
    
  11. Most likely this variable has no value assigned so nothing is printed.
  12. Type the following command
      NOTEXIST=42
    
    42 is printed out since the value of the NOTEXIST variable now has been set to 42.

Links

OS (wikipedia)


Program

Description

Videos

  1. Program (eng) (sv) (download presentation)

Exercises

  1. What is a program? Give some examples of programs.
  2. What is a process?
  3. Give two examples of how a program can be started by a user?
  4. Does a program have to have a GUI (graphical user interface)?
  5. What do you think happens when starting chrome (a browser) from a shell the following way: `chrome http://www.gnu.org`
  6. 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.

  1. A program is a sequence of instructions that a computer with an operating system can execute.
    1. Examples: chrome, firefox, thunderbird
  2. A process is an executing instance of a program?
  3. You can start programs:
    1. from the shell
    2. from a menu system (e.g. start menu)
    3. by clicking a link
    4. ... and probably several more ways
  4. No. Many program have no graphical user interface. These programs are often text based in its communication with the user or system.
  5. Chrome starts up and loads the website http://www.gu.se
  6. There are different names for these arguments:
    1. Command line arguments
    2. Command line option
    3. Program options
    In this course we will use the first (Command line arguments).

Links

Programming with Java book

previous chapter next chapter