Welcome back to McMaster University course Computer Science 1JC3 Introduction to Computational Thinking. I am Bill Farmer. We're going to start a new topic, Operating Systems and the Internet. I'd like to have you look at this movie poster.
This is a poster for the film The Imitation Game and you can see here a picture of Benedict Cumberbatch. He's playing the role of Alan Turing. I consider this a very unique film because this is a Hollywood level film about a logician.
The logician is Alan Turing. Here's a picture of him. We talked about Alan Turing before, but he's a hugely important person in the history of computing. As I say here, he was a brilliant mathematician, logician, and computer scientist from the United Kingdom. He's most known for developing a model of computation based on the idea of a Turing machine.
So this model of computation is relatively close to how computers work today. compared to other models of computation that we've talked about like the lambda calculus and combinatorial logic. As you remember, he and Alonzo Church roughly at the same time showed for the first time that there are undecidable decision problems and this began the outlining of the limits of computing.
Now during World War II, Turing spent his time working on breaking the code of the German Enigma machine. This was a machine that the Germans used widely to encode messages. This was hugely important work for helping the Allies win World War II, the Allies, the British, the Americans, and the Soviets.
The interesting thing is that the world didn't really know about this work by Alan Turing until the 1990s. Until that, it was considered top secret information and was concealed. So this was quite a surprise in the 1990s to find out that this famous... logician actually did something very significant during World War II.
After the war, he worked on designing and using some of the first electronic computers. He designed the computer. called the Automatic Computing Engine, ACE. This was eventually built.
He also got interested in artificial intelligence after World War II, and he developed an ingenious way of measuring intelligence of a machine which is now called the Turing Test. The imitation game is another name for the Turing Test. So the way this test works is very simple.
You have, let's say, a machine that you think is intelligent. So you get a human, and you put the human with the machine, hidden in some way. And then the tester, who's another human, can ask the machine questions and ask the human questions.
The tester, of course, won't know who's answering the questions. So as far as the tester is concerned, they're asking A questions. question, then they ask B. But they don't know if A is the machine or if A is the human and vice versa. So if the human asks these questions, and some of them are answered by the machine, some are answered by the human, and the human cannot tell which of the two, A or B, is the machine, that is evidence that the machine is intelligence.
That's what the Turing test is. Now finally I want to mention that there was never a staff a Nobel Prize for Computing but today there is a is a prize for computing called the Turing Award this is considered equivalent to winning a Nobel Prize and of course it is named after Alan Turing okay so we're going to move on to oh wait I almost forgot I forgot to say something very important about Alan Turing Notice that he was born in 1912 and died in 1954. You can see he lived to be 42. He died very young. The reason he died so young is that quite likely he committed suicide by eating an apple laced with cyanide. The reason this happened is that he was a homosexual and he was hounded by the British government because he was a homosexual who knew a lot of military secrets from his work with the German Enigma machine.
He was convicted of being a homosexual and he was given the choice of chemical castration. So this is using female hormones to basically change him into... change him away from being a man or he could go to prison.
He chose the chemical castration but it's clear he had enough of this and he committed suicide. Now the interesting thing is if you look at the Apple logo on an Apple computer it shows the image of an apple with a bite taken out of it. I had always hoped that this was a tribute to how Alan Turing's life ended, but Apple says there's no connection. Maybe there is. Okay, so let's move on to characters.
So in computing, characters represent graphemes. Graphemes are units of a writing system. Of course, there are many kinds of writing systems.
Each writing system has its own kind of graphemes. So, on computers we need a way of writing things, we need writing systems, we need a way of representing characters. There are two main ways of doing this. ASCII and Unicode. ASCII is a very simple approach.
Unicode is a more of a universal approach. You need to know about both approaches. So ASCII is a character scheme.
And it's based on the English alphabet. In particular, it's based on the symbols from the English alphabet on an old American typewriter. That's really what it's based on. There's 128... characters.
94 are printable. There's a space character and 33 non-printable characters. These non-printable characters are control characters.
Characters that control how you do printing. And since there's 128 characters, we can represent them by either 7 or 8 bits. Now, the non-printable characters are denoted by escape characters. So, for instance, backslash n denotes the new line character the new line character is an example of a control character which is basically saying start printing with a new line so so ASCII is a very biased kind of way of of handling characters because it's basically just the characters of an english alphabet it's not even suitable for closely related writing schemes like german or french So there's a different approach, as I said, a more universal approach called Unicode.
So Unicode is intended to represent the graphemes of basically any of the world's writing systems. And there are more than 130,000 characters now from 139 writing systems. And these characters are represented by either 8, 16 or 32 bits. So, in everyday computer work, people usually use ASCII, but when they're doing something that is going to have interaction with the public, usually Unicode is used. Okay, now we're going to a really big subject, operating systems.
So, if you think about a computer, it's a piece of hardware. How does it run? What controls it? Well, what controls it is the operating system. It controls the computer.
In a sense, a computer is just a piece of hardware that has a program running on it, and this program is the operating system. And the purpose of the operating system is to enable what are called application programs to be executed in the computer. So the operating system is a program, but it's a program to enable.
other programs that run on the computer. Now there have been many operating systems written in the past. If we go back 30 or 40 years ago there were lots of operating systems. Today most computers are using a very small number of operating systems.
The most important examples are Microsoft Windows, Apple's Mac OS X, Linux, and Google's Android. It's important to note that Apple Apple OS X and Linux are both based on Unix. They are really Unix style operating systems. There are many other Unix operating systems as well. So the operating an operating system has two components.
It has the kernel, which is the real heart of the operating system. And this is for controlling the computer's hardware. So an operating system is running in the kernel part control.
to computer's hardware and what it does that's very important it provides services to application programs these are services of the computer's hardware we'll talk in a moment about what these services are so On top of the kernel, we run application programs. And an operating system usually includes a rich set of systems programs. So these are programs that provide...
critical applications for the use of the computer. So if someone is writing a program to run on a computer, they don't have to start from scratch. They can use these systems programs to do all kinds of important things.
Now, the way the kernel works is it provides a set of what are called system calls. And these system calls allow application programs to access the computer's resources. And of course the kernel runs as an infinite loop. It's probably the best example of a program that's intended never to stop It only stopped should only stop When you turn off your computer Okay, so what are the?
Kernel services. What services does the kernel provide for other application programs? Here are the main services. It provides I.O.
device management. So I.O. is input and output.
provides services for all the ways of getting input into the computer and getting output out. It also provides services for executing programs. Today almost all computers work by executing multiple programs simultaneously.
The operating system is designed to handle that. It also handles memory management. So if we have a bunch of application programs running they don't all get get access to all memory. Memory is divided up.
Different programs have access to only certain programs. Some parts of memory are off limits to application programs. And similarly, there's file system management.
There's the management of creating files, having access to files, deleting files, and so forth. So those are kernel services. Now, let's go When a user is going to access an operating system or access any other kind of program, the user needs an interface.
And there's two kinds of interfaces that we're going to talk about, two main kinds, graphical user interfaces and command line user interfaces. So we're going to start with graphical user interfaces. A graphical user interface, it enables the user to have access to the program via a graph. graphical display.
So this is normally a display on the screen of your program, let's say, of your computer. So the screen of your phone, screen of your laptop, screen of a desktop, and so forth. And the display consists of a root window, which may be the whole screen, and various other windows and objects that are placed on the root window.
So you're all familiar with these graphics. user interfaces the user interacts with the interface by initiating events using a mouse or keyboard so for instance you can move your mouse to a certain point click on it that will cause an event and the event that is that is caused depends on where the input focus is so the input focus is where the Interface understands your focus is located. So it will be located on a particular window or a particular part of a window.
So a GUI, a graphical user interface, handles these events as they occur. So it's basically, again, an infinite loop that's just waiting for events to happen, and when they happen, they get handled by the interface. Now, GUIs are interesting because they require a very large portion of the computer's resources. After all, they're handling all these graphics. And for that reason...
they can be very complex but they are relatively easy to use. Many many graphical user interfaces can be used quite easily without ever reading any documentation about how they work. So the other important kind of interface is a command line interface.
A command line interface enables a user to have access to a program via an interactive text-oriented program that runs inside a terminal window. So this is a kind of program you start up what's called a terminal and then you start running the program and the user types things and then gets back responses and for operating systems this program is called a shell and for operating systems you have multiple different kinds of shells So there's things like the C shell, bash, and so forth. Now, the way a shell is going to work, and it's basically the way a command line interface in general works, is the user types a command, the system reads it, the system executes that command, and then the system prints the results, if there are any results, for the user to see. So this could be as simple as working as a calculator. The user types 2 plus 2, the system adds 2 plus 2, gets 4, and then prints 4 on the screen.
So this kind of interface works as a read-execute-print loop and it just executes one command after another. Now the interesting thing is we can collect these commands up and package them into executable programs called shell scripts. scripts.
And this can be a very effective way to control a program or control the operating system. So, command line interfaces use far fewer resources than GUIs and they are much more powerful than GUIs. They have much greater flexibility than GUIs. GUIs are very good for novices they're not good for experts command line interfaces are superb for experts they're not very good for novices the problem the reason they're not good for novices they're very hard to use when you sit down to come command line interface, unless you've read some documentation or you have some experience, you have no idea how to even start. You don't even know what the commands are.
So they are much harder to use, but they are much more powerful. Okay, so we're going to stop here today. And next time, we're going to continue with