L01 Introduction

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 24

0 - Introduction

If you walk up to typical computer today, you're likely to find several applications open. One for listening
to music. One for playing your video game. A web browser displaying information on some ancient culture from
some remote corner of the world. And a messaging application for connecting with friends, and so on.
How is it possible for a single device to do all these things, and moreover, do them all at the same time?
How can all these diverse applications, written by different programmers who don't even know each other,
coordinate? Who's in charge here?
The answer of course is the operating system.
Hello and welcome to CS6210 Advanced Operating Systems. My name is Kishore Ramachandran and I'll be
taking you on a journey to understand the role played by the operating system in providing the rich user experience
afforded to modern applications, the modern computers. And along the way, I'll highlight the symbiotic
relationship between hardware and software that makes it possible for the computer and the operating system to
provide the rich user experience to please you. Operating systems have evolved over time.
In this course we will see all the advances that have been made in the operating system that has led to the state
of the art in operating systems today. Covering a variety of platforms, from cell phones to multi-core, to parallel
systems, to distributive computing and cloud computing.
In part one of this introductory lesson, my goal is to primarily talk about the power of abstraction. That will
lay the foundation for the rest of the introductory lesson, which will include an overview of the hardware resources
managed by the operating system, the operating system functionality that is expected, and the abstractions in an
operating system for managing the hardware resources.
By the end of the lesson, we will be ready to discuss the structure of operating systems.
1 - Background Material

Much of the background that you'll need to know, is covered in this introductory lesson and the review lessons
taught by Charlie Brubaker. However, to get the full benefit of this course, you should have a strong undergraduate
background in computer systems and networks. With that in mind, let's get started with our review and load some
of the operating systems basics into our collective memories.
I've intentionally structured this lesson to be quiz-heavy, since most of the background material should be
already familiar to you. And hopefully that format that I'm going to use, we'll find this to be a more fun way to
jog our collective memories.

2 - Which is an OS Question

4 - The Hierarchy

As computer scientists, one of the most powerful tools that's available to us, is the concept of an abstraction.
And by an abstraction, we mean a well understood interface, that hides all the details within a subsystem. Let's
see how, in a computer system, the hierarchy of abstractions works, and where operating system fits, within this
hierarchy.
5 - Which is Not an Abstraction

6 - Which is Not an Abstraction

Let's walk through all the choices I gave you, and try to understand which can be categorized as an abstraction,
and which is not an abstraction.
• Door knob is something that we use all the time to enter a room, when you open a door. And that's an
abstraction because we don't know how the door knob may actually be implemented, nor do we care. So
that's an abstraction.

• Instruction set architecture of a processor is once again an abstraction, because it tells you what the
processor's capable of doing, not how it is doing it.

• Now the third choice I'm giving you here, is the number of pins coming out of a chip. Now, this is being
very specific as to, what exactly is going on here? That these are exactly the number of pins coming out
of a chip, and therefore it's not an abstraction.

• The next choice is an and logic gate, again here it's only saying what the function of the logic gate is, not
how it is doing it. And therefore, this is an abstraction.

• The next choice is transistor, and this again, is an abstraction, because we don't know how exactly the
transistor is implemented. All we know is a functionality of the transistor. For instance, if a transistor is
used as a switching device, you know that using the transistor you can turn it on and off, but you don't
know what exactly is going on under the covers in order to make that work in the solid state physics.

• The next choice is INT data type. Now, again it's only saying that it is a data type and the name is INT.
And therefore you can use this as a data type that holds integers in your program, but it doesn't tell you
how the data type is actually implemented by the compiler and therefore INT datatype is also an
abstraction.

• The last choice is saying the exact location of base pads in baseball field. Again, this one is being very
specific about some particular feature, namely, base pads and how they're laid out in a baseball field and
therefore, this is not an abstraction.
7 - Digging Deeper Into the Power of Abstractions

Now, let's dig a little deeper into the power of abstraction as it applies to computer systems.

Now, here I'm showing you a screenshot of the Google Earth application.
• Deep down in the silicon, you have electrons and holes. You may have heard about these terminologies
or worked with them in a physics 101 course at some point of time.

• Let's say that in an application such as Google Earth, you move your mouse from Atlanta, Georgia to
Chennai, India. When you do that, magic happens on the screen.

• Now, between a user action, such as moving the mouse from Atlanta, Georgia to Chennai, India, and the
solid state electronics that is enshrined in your computer system, there is a whole series of abstractions.
8 - Name the Abstractions Question

9 - Name the Abstractions Question

Now, I want you to help me think about all the abstractions that sit between these two extremes, Google Earth
application that makes magic happen on the screen and the solid-state physics the electrons and holes enshrine in
your computer system. What are all the abstractions that sit between these two extremes? What I want you to do
in this quiz is to name as many abstractions as you can between these two extremes that I am showing you.

You may have gotten a lot of these abstractions yourself, but let's walk through and think about all the abstractions
that sit between the electrons and holes, and applications at the top.
We've already talked about the transistor, we know at the lowest level of the hierarchy, the movement of the
electrons in the holes, are governed by the laws of physics. And as I mentioned earlier, transistor reigns in the
randomness in the movement of electrons and holes, and gives us an abstraction of a switching device, which is
the transistor.
Using the switching device, which is a transistor, we can implement the next level up in the hierarchy which are
logic gates. Here is where the and- gates and the or-gates and the not-gates come in, where we are implementing
Boolean logic using transistor as a switching device.
Sequential and combination logic elements are implemented using logic gates such as and, not and or logic
elements.
Sequential and combination logic elements are then organized into a data pack, depending on what hardware
circuitry, or functionality we want to implement. The data pack establishes the communication paths we need
between these combinational, and sequential logic elements to realize whatever is the hardware device that we're
trying to design. The control part of it is a finite shaped machine that controls the data path, and implements the
repertoire of the hardware device that we are trying to realize. For instance, if the intent is to implement a
processor, then the instructions in the processor have to be implemented using the data pad, and controlled by the
control logic.
Next level up in this hierarchy is the instruction set architecture. This is the abstraction that is defined by a
processor. When you hear the promo commercial, for instance, that says Intel Inside, it is the ISA, or the
Instruction Set Architecture that is being talked about by the promo. Buried within this term ISA, or the abstraction
ISA, is all the details of how the ISA is actually implemented by the data path and the control logic.
Now we come to software. Sitting on top of the Instruction Set Architecture, is the system software: operating
systems, compilers, run-time systems and so on, that exercise the instructions provided by
the processor architecture.
Finally, we have apps on top. This is where applications like Google Earth come in.
Notice that the abstraction that is used by the applications themselves is the high level language in which these
applications are written. The system software component such as the compiler, translate the high level language
used in writing these applications into the instructions that can be executed on the processor.
Similarly, the operating system provides interface for the applications to request services of the operating system.
For instance, to access specific devices during the execution of the application, or for getting resources such as
memory on demand. Those are the functions provided by the operating system as an abstraction. Thus, the
instruction set is the meeting point between software and hardware. It serves as the abstraction needed by the
system software, for example, the compiler, to generate the code that corresponds to the high-level language
constructs that are being used in coding up an application.
The software, whether it is at the system software level or at the application level does not care and does not know
how this instruction set may actually be implemented down below, meaning the implementation of the instruction
set itself in terms of data path and control, the sequential logic,
Elements that sit below that, are the logic gates of the transistor, or finally the electrons and holes, they don't care
what programs are running on top of the processor.
So the instruction set architecture is the meeting point between software and hardware. The hardware
implementation simply fulfils the contract of realizing the instructions of architecture of the processor.
Operation system is the abstraction level we will be focusing on in this course, which is a course on advanced
operating systems. You will have the opportunity to learn about other levels in this hierarchy, from other courses
that are offered through this program.
10 - Google Earth

Now an application, such as Google Earth, sits at the top of the hierarchy.

And it's code for tracking the mouse movement on the screen, written in whatever high level language is compiled
into the instruction set and traverses the rest of the hierarchy and magic happens on the screen.
Now within this hierarchy, the operating system, acting as a broker between the application at the top and the
physical resources such as CPU, memory, and IO devices, can provide an app with all it needs for its successful
and safe execution.

11 - Conclusion

Most of what we'll be learning in this introductory lesson plan should feel like review to you.
If it has been challenging so far, or becomes challenging as you go through the introductory lesson, it might mean
that you don't have the necessary background for taking an advanced operating systems course.
12 - Introduction

After that fun review of the power of abstractions, next we will take a look at the hardware resources being
managed by the operating system.

13 - Hardware Continuum Question

14 - Hardware Continuum Question


15 - Hardware Resources in a Computer System

So we have this hardware continuum from cell phones and PDAs to laptops, to tablet's, to desktop computers, all
the way to nodes in a data center that is providing cloud computing services.
Regardless of these different manifestations and sizes, the organization of the hardware inside the computer
system is pretty much the same.

You've got a CPU and the CPU is connected to a conduit, which we call the bus.
You've got memory that has the instructions and data that is needed for the CPU to execute.
The CPU can use its conduit, namely the bus, to access the memory.
You need storage for persistence of files and other data that your produce during the computation. Once again the
CPU can access stuff on the student's device through a controller that is also connected to this conduit.
You may have other peripheral devices, like a microphone and a camera. All of these devices, of course, are
accessible for the CPU through this conduit, which is the bus.
Of course in this day, and age a device has to be able to communicate with the outside world. You have a network,
and once again the network is interfaced through a controller to the CPU via this conduit.
This conduit for communication, which is the BUS, serves the purpose of connecting the CPU to the memory as
well as all the I/O devices that it may need to interact with, in order to do whatever the intent is of the user and
the application that they want to run on the computer.
Depending on the sophistication of the device that we're talking about, and the speed of the device that we're
talking about, these controllers that I'm showing you may have different capabilities.
For instance a network controller may have the ability to move the data directly from the memory into the network,
or from the network into the memory (direct memory access DMA) for the controller to move data swiftly between
memory and the I/O device. And similar DMA facility may exist in the controllers of other high speed devices.
So that's the capability that you got for some of these controllers.
Some of these controllers may be slow enough, for instance a keyboard or a mouse, that the CPU can directly
query new data that is coming from the controller that is associated with slow speed devices, and move it into
memory or use it in any fashion that it wants.
16 - Organization With I/O Bus

Here are the more elaborate organization of the hardware resources inside a computer system with an I/O Bus
and a system Bus.
Usually the system Bus is a synchronous communication device between the CPU and the memory. The I/O bus
is primarily intended for the devices to communicate with the CPU.

The intent is that the individual needs of each of these devices, in terms of the communication bandwidth that
they may need is less than the cumulative bandwidth that may be available for the CPU to communicate with the
memory. Or in other words, the system bus has a communication bandwidth that is much more than the
communication bandwidth that's available in the I/O bus.
So the system BUS is a high speed BUS and it connects via a bridge to the I/O BUS.
This bridge itself, could be a specialized I/O processor for scheduling the devices that need to communicate with
the memory for instance, if it is a DMA device or need to communicate with the CPU if it's a slow speed device.
So the role of the bridge is like a processor in itself controlling who has access to this I/O bus among the set of
devices that maybe competing at the same time for attention by the CPU and communicating the intent of these
I/O devices either directly with the memory or via the CPU.
The I/O BUS is typically lower speed than the higher speed system bus. And the cumulative bandwidth that is
needed in the system BUS is usually much higher because it has to cater to all the clients that may want to access
the memory, either from the CPU or from any of these devices coming through this bridge.
There may be other high-speed devices, for example, a frame buffer, of a graphics display that may also be
hanging off of the system BUS due to the need for refreshing the screen in a rapid manner from the memory.
So in a nut shell, if you look at the internal organization of a computer system that are going to be one or more
CPUs, whether it is a single-core machine or multi-core machine or parallel machine and so on, you're going to
have:
• one or more CPUs and you are going to have a bunch of memory that the CPUs can access and there's
going to be a whole number of input-output devices.
• device controllers that allow these devices to communicate with the CPU, or directly with the memory.
• there are conduits, system bus and I/O bus, for connecting these controllers to the CPU as well as to the
memory. Basically, these conduits allow ferrying data from the CPU to the devices, or from the devices
to the CPU, and between CPU and the memory, as well as from the devices to the memory.
This is why I mentioned earlier that there is no difference in the organization, regardless of the platform specifics.
The form factor may be different, or the intended use may be different of a particular platform, but the internal
organization is pretty much going to look as I've shown you here in terms of the hardware elements that are going
to be there as well as the connectivity that you might see among these hardware elements.

17 - The Specifics

The specifics, such as the computational power, the memory capacity, and the number and types of input, output
of devices, may vary from one manifestation of a computer system, to the nex.
For example, commensurate with its intended use, a cell phone or a PDA may have very limited input/output
capabilities such as a graphics display, speakers and microphones.
But on the other hand, a high end supercomputer used for running large scale scientific applications may employ
thousands of CPUs, incorporate several terabytes of memory and be connected an array of disks with storage
capacities on the order of several ParaBytes.

18 - Conclusion

In summary then, the organization of a computer system is consistent enough that many of the key operating
system concepts apply to all of them regardless of size and capacity. On the other hand, these differences should
not be ignored and advances in hardware have helped drive innovation in operating systems, so that we can get
the most out of their capabilities.
19 - Introduction

Now, having reviewed the conceptual tool of an abstraction and the physical resources that is contained in a
computer system, we turn our attention now to the major subject, the operating system. What exactly is the
operating system? Come help me describe one so we want to understand the functionality of an operating system.
20 - OS Functionalities Question

21 - OS Functionalities Question

Now let's talk through the choices I've given you.


Yes, the operating system is a resource manager. It is the boss in control of the hardware resources. So that's a
functionality that you do expect from the operating system.
Yes, the operating system is the entity that provides a consistent interface to the hardware resource. Remember
earlier lecture on obstructions, I mentioned that operating system is a level in the obstruction hierarchy sitting
between the application and the processor and the other resources. So in this sense, the operating system should
be the entity that provides a consistent interface to the hardware resources such as CPU, memory, and I/O devices.
The third choice also seems like a thing that the operating system should do because there could be multiple
applications that require these resources and therefore there has to be an arbitrator that is going to provide a way
of scheduling those requests on the hardware devices. Therefore yes, the OS is an entity that schedules
applications on top of the CPU.
The last choice looks like something that you wouldn't have want the OS to do. And these are personal information
and you would not want the OS to store such information, and therefore this is not a functionality that you expect
of the operating system.
22 - What is an OS

Most concisely, an OS contains code to access the physical resources, that is contained in a computer system,
and arbitrate among competing requests for those hardware resources, coming from multiple applications that
may be running simultaneously on the processing platform.
So in other words, the OS is just a program, like any other program you may have written.
Okay, slightly more complex than a “hello world” program, I'm being facetious here, intentionally. But you get
the point. It's a matter of climbing the latter of programming, just like, a ball player may start from t-ball to little
league to the minor league and then to majors, you can also do it.
If Microsoft can do it, you can do it. If you can write a “hello world” program today, you can eventually write
an entire operating system.

• What the operating system provides are well-defined APIs for accessing the hardware resources that are
managed by the operating system.
• These resources are provided as operating system services through this well-defined interfaces
• An application may make a request to the operating system for such hardware resources through this
well-defined API interface. The application, via the response from the OS, gets the services from the OS
via these API codes.
23 - A Few Examples

Let's start by giving a few examples of how hardware and software interact.
An application asks for and obtains services from the operating system. For example, reading a file that is stored
on the hard drive, or clicking the mouse on Google Earth to take you virtually to some place.
Now let's understand, how the hardware architecture and the system software work together to serve an app
running on the computer system.

24 - Mouse Click Question

25 - Mouse Click Question

As you may have guessed, the right choice is, the most clicked results in a CPU interrupt.
That's the first thing that happens, and once the interrupt has been delivered to the CPU, there are domino
effects that may eventually result in some program running to read the spatial coordinates.
But the thing that happens when you click the mouse is it results in a CPU interrupt.
26 - What Happens When You Click Your Mouse

Let's understand what happens when you click the mouse on your computer.
Let's say you're running the Google Earth application and you select the point that you want to visit on the globe
by clicking the mouse. When you click the mouse, first the hardware controller that is interfacing the mouse,
which is a hardware device.

To the system using the conduit of the BUS is going to raise an interrupt on the interrupt line, which is one of
the dedicated lines on the BUS. This conduit, which I call the BUS, contains data lines and address lines. One of
the things it also contains is an interrupt line or multiple interrupt lines. The controller asserts this interrupt line
to indicate to the CPU that it wants attention. It's sort of like, if I'm teaching a class and you all were a live
audience. If you have a question, you might raise your hand and that's exactly what happens when you click the
mouse.
Asserting the interrupt line on the BUS results in an interrupt to the CPU, now the processor at this point of
time, is running some program. Perhaps your Google Earth application is being run on the CPU at this point of
time. An interrupt is a hardware mechanism for alerting the processor that something external, in this case the
mouse click, requires the attention of the processor. It's sort of like a doorbell in a house. Someone is ringing the
doorbell and someone has got to pay attention to who is at the door.
Remember that the CPU is a dumb animal. All it can do is execute instructions. Right now, it's executing some
application and an interrupt comes in. Some other program has to run on it to field that interrupt. Who's that
entity? That is the operating system.
The operating system, which is also a collection of programs, schedules itself to run on the processor so that it
can answer the doorbell. So the operating system is the one that fields this interrupt, finds out who it is intended
for, and passes it to the program for appropriate action for this particular interrupt.
27 - Introduction

Think back to the beginning of this lesson, where we considered a computer system that was displaying
graphics for a video game, playing music or browsing the web, seemingly all of them at the same time. All of
these applications need access to the physical hardware and they have to be made to share nicely: no hogging
the CPU, no overwriting each other's coder data.
This becomes the job of the operating system, to protect these applications from one another, and to protect an
application from itself. While getting out of the way as quickly as possible so that these applications can do
what they need to do in order to get their jobs done. Now we will discuss the abstractions in an operating
system. From managing the hardware safely and efficiently. Particularly we'll focus on the processor and the
memory.
28 - How is it Possible Question

29 - How is it Possible Question

The right choice is the third one, as you may have guessed.
The operating system is multiplexing the CPU among the competing applications.
You may have multiple cores, but you don't have one core for every application that is currently running on the
CPU.
It may be that you've only have one core, or exactly one CPU, in which case, it is the operating system that is
multiplexing these applications to run at different points of time on the CPU.
That's what is giving you this appearance as though, there are multiple programs running concurrently on the
processor. But they're not running concurrently. It is just that they're being multiplexed, so that its appearance as
though, they're all running in parallel.
30 - Catering to Resource Requirements

The resource needs of the applications include time on the CPU, the memory that it needs for holding its
instructions and data, and peripheral devices that it may have to access during the course of its execution and so
on.
Now, are the resource requirements of a program known to the operating system before you launch it? Well, yes
and no.

• The OS knows enough about the program, at the time of launch, from the disk it can create a memory
footprint for this application. For instance when you click on an icon, a piece of the OS called the OS
loader is reading in the disk resident image of that application, and creating a memory resident image of
that application. This is what is called the memory footprint. And the memory footprint of the program
contains the code that needs to get executed on the processor, global data that it might be accessing, the
stack that is needed when the program is making procedure calls and the heap which is the dynamic
memory that it might be needing during the course of its execution.
• Once a program starts running, can the application ask for additional resources at run time? Of course.
This is exactly the service that is provided by the OS. For example, if the application needs more
memory, it can make a system call and similarly if it needs to make a connection to access a web server
it makes an operating system call. The OS then performs the service on behalf of the application and the
application can then continue with whatever it needs to get done. That's how an operating system caters
to the resource requirements of applications.
So in other words, in addition to catering to the initial requirements of an application at the point of launching it,
the operating system is also the broker through which a running application can request and get additional
resources during its execution.
31 - Precious Resources Question

32 - Precious Resources Question

As you may have guessed, the right choice is no. The OS should not be taking precious resources away from an
application.
For example, if I'm running a program such as, computing the prime number up to a billion, it's going to need a
lot of resources, CPU cycles in particular, and during that time I don't want the operating system stealing cycles
away from me.
OS is also a program and has to run on the CPU as we saw when we talked about how an OS deals with external
interrupts. So it is going to need some resources, CPU and memory cycles to do its work. But a good OS will
take the minimal amount of time and minimal amount of resource to do its thing.
So the right answer is no, as otherwise you will not use an OS.
It's sort of like when give to a charity. The first question you ask is, what percentage of the collection is used by
the charity as administrative overhead? You don't want to give to a charity that spends more than a few
percentage points of the collections on administrative overhead.
Same thing with an operating system. Most of the time, the resources, CPU, memory and so on, is being used
for running the applications. The operating system gets in the way as a broker, only for arbitrating and
providing the resources needed by an application safely and securely, and then gets out of the way as quickly as
possible.
33 - The Modern OS

A modern operating system is a complex piece of software and lots going on, some of which may be completely
outside the user's control. For example, a network message comes in, and your anti-virus software goes into
high gear checking for attacks.
The normal behavior of a good operating system should provide an application with the resources is it asking
for (for example, more memory or access to a file, and so on) and get out of the way, as quickly and quietly as
possible.

34 - Processor Related OS Abstractions

Now, let's get familiar with some of the abstractions provided by an operating system. I'm sure that you may
have heard several different terms used in the context of an operating system such as program or a process or a
thread and task and so on. Let's understand these terms.
A program is the memory footprint that is created when you click on an icon to launch an application on your
favorite platform. So it is a static image of the program loaded into the memory.
A process, on the other hand, is a program in execution. That is, the operating system, breathes life into the
program, which is a static entity, by running the program on the CPU. That is, by scheduling the program to run
on the processor, the operating system gives life to the program and the process is the program in execution.
Therefore a process is the program plus the state of the running program. And yes, the state of the running
program is not static. It is continuously evolving as the program executes. So these are the two important
abstractions related to the process and program:
• program is a static entity created by the operating system when you launch a program
• process is the program in execution.
35 - Difference Between Process and Thread

Now you've heard the term thread. Well, it's also used in the context of an operating system.

What is the difference between a process and a thread? An analogy will help here. Let's say here is the morning
newspaper. This morning newspaper lying on the dining table is like a program in memory. No life. I come to
the dining table, pick up the sports section of the newspaper and start reading it. My starting to ready the sports
section of the newspaper is akin to the OS giving life to the program by starting to execute it. So, now there is
one life in the program. That is one line of control that is coursing through the core and data structures of the
program. This is what is called the thread of execution through the program. Now, my wife comes along, and
being the more responsible one in the family picks up the business section and starts reading it. That's perfectly
fine, depending on our interests, I'm reading the sports section while wife is reading the business section, each is
reading a different section of the same newspaper.
Similarly, we can have multiple lives, coursing through the program, each blazing a completely different trail
through the code and data structures of the program. Now each of this is a thread of control.
Now could there be a conflict between these different threads of control? Sure. Both my wife and I may want to
read the same section of the newspaper. That's a conflict. Similarly. The threads that are executing within the
same program may want to read or update the same data structures. These are the issues that the operating
system has to deal with, and this is what I meant when I said that the operating system is the arbitrator for
completing requests for resources.
Now generalizing it.
• A program can have several threads of control, and each thread of control maybe coursing through
different sections of the program.
• It could also be competing for the same section of the program as well as the same data structure in
order to manipulate.
• Thus, a process is a program plus the state of all the threads that are executing within the program. Just
as a single newspaper could be shared by me, my wife, and possibly my children. In a similar manner, a
program may have multiple lives that are coursing through it.
• For example, if this program is a web browser, one thread in this program could be fetching a page that
I've requested from the remote server and another thread could be painting the screen for me.

36 - Memory Related OS Abstraction

How is one program, let's say an email, protected from the misbehavior of another program, say the web
browser? This is where memory related operating system abstractions come into play.
In particular, the OS provides address space as an abstraction for each process that is distinct from one
another. So the data and the code that corresponds to a particular program is contained in a container which is
called the address space. That's the abstraction provided by the operating system.
This address space abstraction of the OS is implemented by whatever hardware capabilities that the
underlying processor architecture provides you. Processor and memory are the most precious resources. And
what we've done is a quick review to understand the abstractions in the operating system for managing these
resources.

37 - Conclusion

Until now, what we have seen in this lecture is a quick review of the concepts that you are most likely already
familiar with.
The next lesson will launch into the evolution of the operating system's structure.
Before we get into that lesson, if you feel you could benefit from reviewing the basic concepts of an
operating system. I strongly recommend that you review the basic subsystems of an operating system: CPU
scheduling, memory management and the network protocol stack.
To help you navigate this background material, my tall friend here, Charlie Brubaker has produced lecture
materials that are available as part of this course offering.

You might also like