Introduction To Operating System
Introduction To Operating System
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.
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.
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.