(Audio for this slide is split into several audio files, one for each
step of the animation. In contrast, these notes contain a transcript
of all animation steps.)
Although the Hack computer does not have an OS, it
will help to recall briefly how you interact with that machine.
On Hack, you are able to run a single program, where you access
hardware directly. E.g., reading from the keyboard requires access to
a special memory location that represents the state of the underlying
hardware device.
With OSs, applications no longer have direct access to hardware.
Instead OSs manage applications and their use of hardware.
You will learn that the core part of OSs is called
kernel ,
and each vendor’s kernel comes with a specific interface to provide
functionality to applications, usually in the form of so-called
system calls .
E.g., when you use System.in
in Java to read keyboard input,
the Java runtime executes a system call to ask the OS for
keyboard input.
Starting from system calls, we will look into techniques for
input/output processing
(I/O for short) such as access to the keyboard. Recall that in Hack
you programmed a loop to wait for keyboard input. Clearly, such a
loop keeps the CPU busy even if no key is pressed, wasting the
resource CPU if other application could perform useful computations.
Hence, I/O is usually paired with
interrupt processing ,
which does not exist in Hack. Briefly, interrupts indicate the
occurrence of external events, and OSs come with
interrupt handlers .
Then, for example, keyboard processing code only needs to be executed
when a key was pressed.
In contrast to Hack, OSs manage the execution of several applications,
and each application might contain several so-called
threads of execution. It is
up to application programmers to decide how many threads to use for a
single application (and you will create
threads in
Java ).
The OS manages all those threads and their
scheduling for execution
on the CPU (or their parallel execution on multiple CPU cores).
Usually, scheduling mechanisms involve
time slicing , which means
that each thread runs for a brief amount of time before the OS
schedules a different thread for execution. Such scheduling happens
in intervals of about 10-50ms, creating the illusion of parallelism
even if just a single CPU core exists. Such time-sliced or parallel
executions are also called
concurrent executions.
If shared resources are accessed in concurrent executions, subtle bugs
may arise, a special case of which are update anomalies in database
systems. The notion of
mutual exclusion (MX)
generalizes several synchronization mechanisms to overcome concurrency
challenges, and we will look at typical related OS mechanisms and
their use in Java.
Just as in Hack, instructions and code of applications need to be
stored in memory. Differently from Hack with its Harvard
architecture, code and instructions are stored uniformly in RAM in our
Von Neumann machines, and the OS manages the allocation of RAM.
Importantly, mainstream OSs provide support for
virtual memory,
which does not exist in Hack, but for which we will see advantages
such as isolation and flexibility.
Furthermore, mainstream OSs offer a
process
concept as abstraction for applications, under which several related
and cooperating threads share resources (such as virtual memory or
files). Finally, OSs offer various
security
mechanisms for processes and applications, a selection of which will
be topics for the final presentation.
To sum up, this figure visualizes
what OS topics will be discussed when and
how topics build upon each other.
Note that some parts of this figure are hyperlinked to other
presentations, which the mouse pointer should indicate.