The Mechanism of a Computer
A washing machine washes clothes using a motor, and a rice cooker heats up rice using a heater. How does a computer work?
- When buying a beverage from a vending machine, what is the input, what kind of process is being executed and what is the output?
- In Exercise07-5, what is the input, process and output.
- On Exercise 09-5, where are
ex09-5.jsstored ? Primary or secondary storage?
- When the “pocket” button is clicked, another “Inside the pocket, there’s two cookie” shows up. In which memory is this message saved on?
- When the page is reloaded, the screen returns to a single “Inside the pocket, there’s one cookie”. What happened to the data in the primary and secondary memories?
- Start up the Activity Monitor(Applications→Utilities).
- The usage of the CPU is displayed under the “CPU” tab. Open any application and see what happens.
- Check the disk activity monitor. Open any application and see what happens.
The Operating System(OS) is software to manage the computer. The basic functions of an operating system are:
- 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.
- 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)
The state of an application being executed is called a “process”. The operating system manages processes, and terminates programs accordingly.
- Start up the activity monitor and check what processes are in motion.
- Click “%CPU”, and line the processes in order of CPU usage.
- Operate the browser and editor and see if the order changes.
- Terminate a process by clicking on the apple mark.
- A warning should come up. Explain what this means from the point of view of primary and secondary memory.
We studied about file systems in Lesson 3, and the main points are:
- 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).
ex10-5.txtinside the directory “fundamentals of information technology” we made (or any other directory you like), and write something in it.
- Confirm the absolute path of
- With Atom, click the file name on the bottom left
- With Emacs, the command
M-x pwdwill show the directory.
ex10-5.txt(drag with holding the option key) to the desktop.
- Open the file and compare the absolute path from before.
- Write a different text from the original file and save it.
- Did the content of the original file change?
- Make an alias of
ex10-5.txt（option key + command key + drag, or right click the file and select “Make Alias”)
- Open the alias and change the content.
- Did the content of the original file change?
- Delete the original file.
- What happens when the alias is opened by the editor?
- Copy will create a different file with the same content. Files with the same name will be treated as a different file as long as they exist in different directories.
- Alias adds a different name for the same file. Even if the file name is different, it is still the same file.
In some cases, you don’t want other users to be able read and write your data. In that case, you change the file permissions.
Normally, users work on their own directory and set the accessing authorization so that other users can’t overwrite any files. However, a file can be shared to the public by changing the permission. Let’s use the shared region and practice.
ex10-6.txtwrite something in and save the file.
- 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.
- 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.
- 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?
- Right-click the file and select “Get Info”
- 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?
- 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
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 3 and 5. Try doing this with your computer.
- Edit Exercise 09-6 and display numbers from 1 to 30 in order (use a loop).
- How should we draw the flowchart (the diagram below) of the program? What goes into the condition and the process part?
- First, be able to display “Fizz” when the number is divisible by 3. Where should we place the conditional branch(in the flowchart)?
- Make an 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 3 is 0”. The operant of a remainder is “%”. When we want to find out the remainder of a variable named “count” when divided by 3, we write
count % 3.
- Display “Fizz Buzz” when the number is divisible by 3 and 5.
- Display “Buzz” when the number is divisible by only 5.
Display numbers from 1 to 99, and add “Ooops!” after numbers in case:
- The number is divisible by 3.
- The number contains 3 either on the one’s or ten’s place (such as 13 and 38).
If possible, use only one “if” statement. (Make a condition with logical operators)
- 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?