No.10 How a Computer Works

The Mechanism of a Computer

A washing machine washes clothes with a motor, and a rice cooker heats up rice with a heater.  How does a computer move?

(Download PPT)

Template for “Spec of PC” (DOC | PDF)

Exercise 10-1(☆)
  1. What is input, output, and processed in a vending machine.
  2. On Exercise07-5, what is the input, output, and processed.
Exercise 10-2(☆☆☆)
  1. On Exercise 09-5, ex09-5.html and ex09-5.js are saved on secondary memory, but what is saved on primary memory?
  2. When the “pocket” button is clicked, another “Inside the pocket, there’s two cookie” shows up. Which memory is this message saved on?
  3. When the page is reloaded, the screen returns to a single “Inside the pocket, there’s one cookie”.  What kind of data is exchanged between the primary and secondary memories?
Exercise 10-3(☆)
  1. Start up the Activity Moniter(Appications→Utilities).
  2. The usage of the CPU is displayed under the “CPU” tab.  Open some apps and see what happens.
  3. Check the disk activity monitor.  Open some apps and see what happens.

With Windows8, the CPU usage can be displayed with the Task Manager

Operating System

The Operating System(OS) is software used to manage the computer.  The OS have the following functions.

Process Management
Manages the start-up, execution, termination of software.
Device Driver
The device driver manages parts of input and output to simplify the application.
File System
The unit “file” and “directory” is used to manage data easily on secondary memory.
Manages accessing authorization of data and hardware.
User Interface
A computer is operated by GUI and CUI.

Operating systems of the following are broadly used.

Windows, MacOS, Linux(Ubuntu, etc)
Smart Phone
iOS, Android (Linux is used for kernel)
Windows Server, Unix(Solaris, etc), Linux(RedHat, etc), Mainframe(z/OS, etc)

Process Management

The state of an application being executed is called a “process”.  The operating system manages processes, and terminates programs when neccessary.

Exercise 10-4(☆☆)
  1. Start up the activity monitor and check what processes are in motion.
  2. Click “%CPU”, and line the processes in order of CPU usage.
  3. Operate the browser and editor and see if the order changes.
  4. Terminate a process by clicking on the apple mark.
  5. A warning should come up.  Explain what this means from the point of view of primary and secondary memory.

Processes can be terminated on Windows8 with the task manager.

File System

We studied about file systems in Lesson 3,、but let’s review.

  • Contents of secondary storages are managed by directories (folders) and files.
  • Two files with the same name can be made if their directories are different.  To distinguish files of the same name, we need to use path names (absolute or relative).
Exercise 10-5(☆☆)
  1. Make ex10-5.txt inside the directory “fundamentals of information technology” we made (or any other directory you like), and write something.
  2. Confirm the absolute path of ex10-5.txt via editor.
    • With mi, it is displayed on top(/automount...)
    • With Emacs, the command M-x pwd will show the directory.
  3. Copy ex10-5.txt (drag with holding the option key) to the desktop.
  4. Open the file and compare the absolute path from before.
  5. Write a different text from the original file and save it.
  6. Did the content of the original file change?
  7. Make an alias of ex10-5.txt(option key + command key + drag, or right click the file and select “Make Alias”)
  8. Open the alias and change the content.
  9. Did the content of the original file change?
  10. Delete the original file.
  11. What happens when the alias is opened by the editor?
  • Copy will create a different file with the same content.  Even if the file has the same name, as long as it exists in a different directory it’s a different file.
  • Alias adds a different name for the same file.  Even if the file name is different, it is still the same file.

There are cases when other users read and write the file, so there is the need to set accessing authorization to each file or directory.


Normally, users work with their own directory and set the accessing authorization so that other users can’t overwrite any files.  However, if the settings are changed, a file can be accessed by anyone.  Let’s use the shared region and practice.

Exercise 10-6(☆☆☆☆)
  1. Make ex10-6.txt write something, and save the file.
  2. Select “Move to…” from from Finder and display the content of /pub/sfc/ipl/info1-free.  This is a shared region where anyone can make files.
  3. Move ex10-6.txt to /pub/sfc/ipl/info1-free.
  4. If the file with the same name has already been made by someone else, the file cannot be moved(because you don’t have the authorization to overwrite files.)  Change the file name and try moving the file.
  5. Ask the file name of your neighbor’s, and try opening the file with a editor.  What happens when you change the content and save the file?
  6. Right-click the file and select “Get Info”
  7. On the buttom of the info window, there is “Sharing and Permission” section.  “Everyone” is the column of authorization for other users.  What is it set to?
  8. Ask your neighbor to change the authorization of “Everyone” to read/write, and see if you can edit the file now.

Reviewing if Statements and Loops

We studied if statements and loops before.  Now, let’s try combining the two.

There is a game called Fizz Buzz.  We count up from the number 1, and when the number is divisible by 3 we say “Fizz”, “Buzz” when the number is divisible by 5, and “Fizz Buzz” when the number is divisible by both.  Let’s try doing this with a computer.

Exercise 10-7(☆☆☆)
  1. Edit Exercise 09-6 and display the numbers from 1 to 30.
  2. How should we draw the flowchart(the diagram below) of the program? What goes into condition and process part?
  3. First, display Fizz when the number is divisible by 3, and display numbers when not.  Where should we place the conditional branch(in the flowchart)?
  4. Make a if statement of the flowchart you drew.  The condition “divisible by 3” is written in a program as “when the remainder of a number divided by three is 0”.  The operant of a remainder is “%”.  When we want to find out the remainder of count, we write count % 3.
  5. Display Fizz Buzz when the number is divisible by 3 and 5.
  6. Display Buzz when the number is divisible by only 5.
Exercise 10-8(☆☆☆☆☆)

Let’s make another game. Display numbers from 1 to 99, and add “Ooops!” after numbers in case:

  • the number is divisable by 3, or.
  • the number contains digit 3 (either the digit of 10’s place or 1’s place is 3).

If possible, use only one “if” statement. (Make a condition with logical operators)

Points to Check
  • What 5 functions are there in a computer.
  • How can we measure the performance of a CPU?
  • What is the difference of a primary and secondary memory?
  • What is a process?
  • Why is the access authorization set?