Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
56 views

Introduction To Operating System

This document provides an introduction to operating systems. It discusses: 1) What an operating system is - it implements a virtual machine that abstracts away the raw hardware and provides standard services to applications. 2) The two main functions of an operating system are resource allocation/control to allow efficient sharing of hardware among applications, and standard services to facilitate application programming. 3) Examples of what is typically included in an operating system are memory management, I/O management, CPU scheduling, and communications, while file systems and user interfaces may or may not be considered part of the core OS.

Uploaded by

Debashish Pal
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
56 views

Introduction To Operating System

This document provides an introduction to operating systems. It discusses: 1) What an operating system is - it implements a virtual machine that abstracts away the raw hardware and provides standard services to applications. 2) The two main functions of an operating system are resource allocation/control to allow efficient sharing of hardware among applications, and standard services to facilitate application programming. 3) Examples of what is typically included in an operating system are memory management, I/O management, CPU scheduling, and communications, while file systems and user interfaces may or may not be considered part of the core OS.

Uploaded by

Debashish Pal
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

CS162 Operating Systems and Systems Programming Application

Virtual Machine Interface


Professor: Anthony D. Joseph
Operating System
Spring 2003
Physical Machine Interface
Hardware
Lecture 1: Introduction
0.0 Administrivia:
In some sense, OS is just a software engineering problem: how do you convert
1.0 Main points: what the hardware gives you into something that the application programmers
want?
What is an operating system --- and what isn’t it?
Principles of operating system design
For any OS area (file systems, virtual memory, networking, CPU scheduling), you
Why study operating systems?
begin by asking two questions:
1.1 What is an operating system? • What’s the hardware interface? (the physical reality)
• What’s the application interface? (the nicer abstraction)
Of course, should also ask why the interfaces look the way they do, and whether it
might be better to push more responsibilities into applications or into hardware, or
vice versa. (examples, RISC architectures, VBasic libraries, etc.)

1.1.1 Virtual Machines


• Virtual machine model provides software emulation of an abstract machine
API:
Application • Also used to allow programs for one hardware & OS platform to run on
Programming another one (e.g., Windows programs on a Macintosh), perhaps even running
Interface several VMs concurrently.
• Useful for OS research and development (much easier to debug)
Hardware
Interface • Protection and portability (e.g., Java VM)
• The project in this course is to build some of the portable components of an
OS on top of Nachos, which provides a simulation environment. That is, it
simulates the hardware and machine-dependent layer (interrupts, I/O, etc.) and
the execution of user programs running on top of it. Note that Nachos runs on
(Figure is from Silberschatz and Galvin, Chapter 1) many different hardware/OS platforms.

Definition: An operating system implements a virtual machine that is (hopefully)


1.1.2 Operating systems have two general functions:
easier and safer to program and use than the raw hardware.
Silberschatz and Galvin: “An OS is similar to a government”.
This becomes political --- do you think a government does anything useful
by itself?

CS 162 Spring 2003 Lecture 1 1/9 CS 162 Spring 2003 Lecture 1 2/9
1.1.5 Simple OS: What if only one application at a time?

1. Coordinator & traffic cop: allow multiple applications/users to work Examples: very early computers, early PC’s, embedded controllers (elevators,
together in efficient and fair ways (examples: concurrency, memory cars, Nintendos, ...), PDAs, intelligent light switches,…
protection, file systems, networking). This is Resource Allocation and
Control. Goals are fair management of shared resources, protection, and Then OS is just a library of standard services. Examples: standard device drivers,
efficiency. interrupt handlers, math libraries, etc.

2. Standard services: provide standard facilities that everyone needs (examples: 1.1.6 More complex OS: what if you want to share the machine among multiple
standard libraries, windowing systems). View OS as a facilitator. Goal is to applications?
make application programming easier, faster, and less error-prone.
Then OS must manage interactions between different applications and different
1.1.3 So, what is in an OS and what isn’t? users, for all hardware resources: CPU, physical memory, I/O devices like disks
and printers, interrupts, etc.
Of course, there is no universal agreement on this but:

Most likely: Of course, the OS can still provide libraries of standard services.
• Memory management
• i/o management
• CPU scheduling 1.1.7 Example of OS coordination: protection
• communications?
• multitasking/multiprogramming
Problem: How do different applications run on the same machine at the same
What about?:
time, without stomping on each other?
• File System
• Multimedia support
• User Interface (window manager) Goals of protection:
• Internet Browser? ☺ • Keep user programs from crashing OS
• Keep user programs from crashing each other
Bonus question: is this just of interest to academics? If not then why might it be
important?

1.1.4 What if you didn’t have an operating system? 1.1.7.1 Hardware support for protection
Hardware provides two things to help isolate a program’s effects to within just
source code -> compiler -> object code -> hardware that program:
• Address translation
How do you get object code onto the hardware? How do you print out the • Dual mode operation
answer? Before OS’s, used to have to toggle in program in binary, and then read
out answers from LED’s!

CS 162 Spring 2003 Lecture 1 3/9 CS 162 Spring 2003 Lecture 1 4/9
1.1.7.2 Address translation
Address space: literally, all the memory addresses a program can touch. All the code data2 code
state that a program can affect or be affected by. stack1
data data
code1
Achieve protection by restricting what a program can touch! heap heap
heap1
Hardware translates every memory reference from virtual addresses to physical stack code2 stack
addresses; software sets up and manages the mapping in the translation box.
prog 1 stack2 prog2
Physical data1
Virtual virtual virtual
Address Physical
Address Translation address heap2 address
Box Memory space space
CPU (MMU) OS code

OS data

OS heap
& stacks

physical
Data read or write
memory
(untranslated)
Example of Address Translation
Address Translation in Modern Architectures
Two views of memory:
Translation helps implement protection because there is no way for a program to
• View from the CPU – what program sees, virtual memory
even talk about other program’s addresses; no way for it to touch operating
• View from memory – physical memory
system code or data.
Translation box (also called a memory management unit) converts between the
two views.
Translation also helps with the issue of how to stuff multiple programs into
memory.

Translation is implemented using some form of table lookup (we’ll discuss


various options for implementing the translation box later). Separate table for
each user address space.

CS 162 Spring 2003 Lecture 1 5/9 CS 162 Spring 2003 Lecture 1 6/9
1.2.4.3 Dual mode operation
Can an application modify its own translation tables? If it could, then it could get
1.2 Operating Systems Principles
access to all of physical memory. Has to be restricted somehow.
Throughout the course, you’ll see four common themes recurring over and over:
Dual-mode operation
• When in the OS, can do anything (called “kernel mode”, “supervisor OS as illusionist – make hardware limitations go away. OS provides illusion of
mode”, or “protected mode”) dedicated machine with infinite memory and infinite processors.
• When in a user program, restricted to only touching that program’s memory
(user-mode) OS as government – protect users from each other and allocate resources
Implemented by setting a hardware-provided bit. Restricted operations can efficiently and fairly.
only be performed when the “kernel-mode” bit is set. Only the operating
system itself can set and clear this bit. OS as complex system – keeping things simple is key to getting it to work; but
there is a constant tension between this and the desire to add more functionality
HW requires CPU to be in kernel-mode to modify address translation tables. and performance.

OS as history teacher – learn from past to predict the future in order to improve
Isolate each address space so its behavior can’t do any harm, except to itself. performance.

1.3 Why study operating systems?

Application You need to understand enough to make informed decisions about things like:
• Buying and using a personal computer:
User mode
• Why do different PCs with the same CPU perform differently?
Standard library • How do I choose between an Intel Celeron and Pentium II CPU?
• Should I get Windows 2000? Windows NT? Unix? What’s the difference?
• Should I upgrade my hardware? Should I upgrade my OS?
• What’s going on with my PC, especially when I have to install something?
Portable OS layer • Should I use disk compression? Is there a cost to using it?
Kernel mode
• …
• Business (and personal) decisions about NCs vs. NetPCs vs. PCs:
Machine-dependent OS layer • What are the issues involved?
• What kinds of choices are being offered?
Hardware • Business decisions in general: how important are various capabilities (such as
Typical UNIX Operating System Structure fault tolerance) and what should they cost?
• Security and viruses: what exposures do I have to worry about?
Remember: don’t need boundary between kernel and application if system is • Why is the Web so slow sometimes and is there anything I can do about it?
dedicated to a single application.

CS 162 Spring 2003 Lecture 1 7/9 CS 162 Spring 2003 Lecture 1 8/9
If you’re going to be a software engineer then you’ll need to understand various
things about the environment offered by the OS you’re running on:

• What abstractions does the OS provide? E.g., the OS may (or may
not) provide illusions such as infinite CPU’s, infinite memory, single
worldwide computing, etc.
• What system design trade-offs have been made? E.g., what
functionality has been put in hardware? What trade-offs have been
made between simplicity and performance, putting functionality in
hardware vs. software, etc?
Capstone: combines things from many other areas of computer science –
languages, hardware, data structures, and algorithms; In general, systems smarts,
complex software development (in groups), and intuition for general systems
tradeoffs.

CS 162 Spring 2003 Lecture 1 9/9

You might also like