CS 321 Spring 2013 > Lecture Notes for Friday, January 18, 2013 |
This class is about:
In particular, we are not here to do a survey of the various OSs out there. We will consider concepts from the point of view of low-level applications programming. Most of our practical examples will involve Linux, or, more generally, the *ix family of operating systems.
In this class we will focus on three abstractions that operating systems provide.
We will proceed through the text largely in order, covering much of the first six chapters. After the introductory material, there will be one chapter on each of the above abstractions. Then we look at some of them in more detail.
When we do abstraction, we deal with something through a well-defined interface, without having to worry (much) about what is behind the interface. For example, a function is an abstraction. We call a function, passing it the appropriate parameters, without having to know exactly what its body looks like.
We use the word “virtual” to refer to things having the same interface, possibly with different things behind the interface. For example, we usually deal with the system keyboard using a virtual file.
We used a Linux shell to look at examples of virtual files: keyboard input, screen output, pipes, named pipes.
Here are some examples.
cat < abc > def1 sort < abc > def2 uniq < abc > def3
Each of the above three command lines
reads from file abc
and writes to a def
... file.
The first sends the contents of abc
to file def1
, unchanged.
The second sorts by line before writing.
The third removes duplicate consecutive lines before writing.
The arrows
(“<
”,
“>
”)
indicate the direction of data flow.
cat > def
The above
reads from the terminal (keyboard?)
used as a virtual file.
and writes to file def
.
sort < abc
The above
reads from file abc
,
sorts by line,
and writes to the terminal,
used as a virtual file.
cat < abc | sort | uniq
The above
reads from file abc
,
sorts by line, removes duplicate lines,
and writes to the terminal.
This comamnd line includes two uses of a pipe:
a virtual output file connected to virtual input file.
mkfifo mypipe cat < abc | sort > mypipe
And then, in another terminal window:
cat < mypipe | uniq
The above two together have the same effect as before,
but they create and use the named pipe mypipe
.
This is much like the pipe used earlier,
except that looks like a file in the current directory.
Source files
halflines.cpp
[C++ source]
and
revlines.cpp
[C++ source]
were used in class.
The obvious question is “What is an operating system?” But we will not answer it. We prefer to ask, “What do operating systems do?” Then we will spend the semester discussing how to do those things.
We can divide the answers to our question into two categories.
The various software packages that we usually call “operating systems” (Windows, MacOS, Linux, iOS, Android, etc.) fit the above ideas very well. But web browsers do, too; they provide services to the programs (usually written in Javascript) that are executed in them. So, is Mozilla Firefox an operating system? Maybe, but does it matter? Not really.
There are essentially four reasons to have an OS.
Note that the first two reasons above relate mainly to the OS’s role as an extended machine, with the last two relate mainly to the resource-manager role.
We can divide a computer system into four parts: application programs, operating system, hardware, users. The applications interact only with the OS. Users interact only with the hardware. The OS functions as an interface between the applications and the hardware. A diagram is shown below.
Note that users might feel as if they are interacting directly with an application; but they never actually do. Thus, an important responsiblity of an OS is to represent the user to applications.
ggchappell@alaska.edu