What is an Operating System? CS 450 : Operating Systems Michael - - PowerPoint PPT Presentation

what is an operating system
SMART_READER_LITE
LIVE PREVIEW

What is an Operating System? CS 450 : Operating Systems Michael - - PowerPoint PPT Presentation

What is an Operating System? CS 450 : Operating Systems Michael Saelee <saelee@iit.edu> Agenda - what is an operating system? - what are its main responsibilities & how does it achieve them? - how is an operating system organized? -


slide-1
SLIDE 1

What is an Operating System?

CS 450 : Operating Systems Michael Saelee <saelee@iit.edu>

slide-2
SLIDE 2

Agenda

  • what is an operating system?
  • what are its main responsibilities & how does it achieve them?
  • how is an operating system organized?
  • what is an operating system kernel?
  • OS timeline
slide-3
SLIDE 3
  • perating system

noun the software that supports a computer's basic functions, such as scheduling tasks, executing applications, and controlling peripherals.

New Oxford American Dictionary

slide-4
SLIDE 4

tasks & applications = running programs = Processes peripherals = I/O devices

slide-5
SLIDE 5

OS duties revolve around aiding and abetting user processes

  • setting up a consistent view of system for each process
  • simplifying access to and tracking the use of system resources
slide-6
SLIDE 6

tasks & applications = running programs

  • additional implication: many processes running concurrently
  • all modern OSes also have to support concurrent execution
slide-7
SLIDE 7

Problem: there are never enough resources!

  • OS multiplexes (time/space) and virtualizes hardware for

running processes

slide-8
SLIDE 8

Processes typically run in volatile memory — it’s important to save results in persistent storage during and after execution Also, in the event of errors/crashes, persistence is useful for recovery!

slide-9
SLIDE 9

primary OS services:

  • hardware abstraction (virtualization)
  • concurrency
  • persistence
slide-10
SLIDE 10

With all this virtualization and concurrency, it is critical that processes be protected and isolated from one another (and the

  • perating system)
slide-11
SLIDE 11

How to enforce protection/isolation? Two routes: software / hardware

slide-12
SLIDE 12

Is isolation possible solely via software? I.e., can you write a program (the OS) to execute other (user) programs, and guarantee separation & robustness 
 without hardware support?

slide-13
SLIDE 13

Some software attack vectors:

  • address fabrication (e.g., integer-to-address cast for cross-

space pointers)

  • buffer overruns (e.g., on syscalls)
  • run-time errors (e.g., intentional/accidental stack overflows)
slide-14
SLIDE 14

Software prevention mechanisms:

  • static verification (e.g., type-checking) — programs must

“pass” to be run

  • run-time tools (e.g., garbage collection, exception handling)
slide-15
SLIDE 15

Is isolation possible solely via software?

  • maybe — but difficult/impractical
  • the popular approach (all commercial OSes) is to rely on

hardware support

slide-16
SLIDE 16

e.g., Intel x86 architecture provides a 2-bit current privilege level (CPL) flag

  • implements 4 protection ring levels

1 2 3 most to least privileged

slide-17
SLIDE 17

CPL=3 ➞ “user” mode CPL=0 ➞ “supervisor/kernel” mode

  • access to special instructions 


& hardware

slide-18
SLIDE 18

How to modify CPL? Q: Ok to allow user to directly modify CPL before invoking OS? A: No! User can set CPL=0 and run arbitrary code before calling OS

slide-19
SLIDE 19

Q: What about combining CPL “set” instruction with “jump” instruction to force instruction pointer (eip) change? A: Bad! User can set CPL=0 and jump to user code to masquerade as OS.

slide-20
SLIDE 20

Q: What about combining CPL “set” instruction with “jump” instruction that must target OS codespace? A: Not good enough. User code may jump to delicate location in OS.

slide-21
SLIDE 21

Solution: x86 provides int instruction:

  • sets CPL=0
  • loads a pre-defined OS entry point from interrupt descriptor

table (IDT)

  • IDT base address can only be set when CPL=0 (by privileged

lidt instr)

slide-22
SLIDE 22

Privileged instruction & hardware access prevented, but how is memory protected?

  • Each segment/page of memory in x86 is associated with a

minimum CPL

  • Only permit current process to access its own (user level)

segments/pages

slide-23
SLIDE 23

Finally, how can OS regain control from unruly user process? (E.g., running in tight loop, never executing int)

  • hardware sends periodic clock interrupt
  • preempts user; summons OS
slide-24
SLIDE 24

Isolation accomplished. How to achieve h.w. abstraction & concurrency?

slide-25
SLIDE 25

h.w. abstraction = user traps to OS (via int) with service request; OS carries out task and returns result — “syscall” i.e., hardware (e.g., NIC) is exposed as a software stack (e.g., TCP/IP)

slide-26
SLIDE 26

concurrency = clock interrupt drives context switches and hardware multiplexing, carried out by OS scheduler (and others) enables multitasking on limited hardware (compare to parallelism)

slide-27
SLIDE 27

Different approaches to multitasking:

  • cooperative: processes voluntarily control
  • preemptive: OS periodically interrupts
  • real-time: more stringent requirements
slide-28
SLIDE 28

§ How is an OS organized?

slide-29
SLIDE 29

i.e., what are the top-level modules of an OS, and which must run in privileged mode (e.g., CPL=0)?

slide-30
SLIDE 30

some modules:

  • virtual memory
  • scheduler
  • device drivers
  • file system
  • IPC
slide-31
SLIDE 31

privileged modules constitute the “core” of the operating system; i.e. the OS kernel

slide-32
SLIDE 32

traditional approach: all are privileged

  • i.e., entire “OS” runs in kernel mode
  • known as monolithic kernel
  • pros/cons?
slide-33
SLIDE 33

alternative approach: minimum privileged

  • i.e., have a “microkernel” with minimal set of privileged

services

  • everything else runs in user mode
  • microkernel relays requests
  • pros/cons?
slide-34
SLIDE 34

courtesy of Wikimedia Commons

slide-35
SLIDE 35

… suffice it to say that among the people who actually design operating systems, the debate is essentially over. Microkernels have won

  • Andrew Tanenbaum


(noted OS researcher)

slide-36
SLIDE 36

The whole “microkernels are simpler” argument is just bull, and it is clearly shown to be bull by the fact that 
 whenever you compare the speed of development of a microkernel and a traditional kernel, the traditional kernel

  • wins. By a huge amount, too.
  • Linus Torvalds


(chief architect, Linux)

slide-37
SLIDE 37

summary and your opinion? ➞ assignment 1 (paper)

slide-38
SLIDE 38

Yet another route: why not just implement OS as a low-level library?

  • loss of isolation, but big efficiency gain (and flexibility in

using h.w. directly)

  • used by many embedded systems
slide-39
SLIDE 39

And finally, what about hosting multiple OSes on a single machine? (Useful/feasible on large, multi-core machines)

  • hypervisors provide low-level virtual machines to guest OSes
  • yet another layer of isolation!
slide-40
SLIDE 40

§ OS timeline

slide-41
SLIDE 41

1950s: Punchcards & Batch 
 processing

  • a program is completely defined by a 


“batch” of punchcards

  • batches are manually fed into mainframes, which execute a

single batch at a time (a “job”)

  • programmer defines any and all routines needed for the job
slide-42
SLIDE 42

1950s-1960s: Support libraries

  • useful, reusable routines (e.g., for math, I/O)


distributed as collections of punchcards

  • these routines can be “linked” (statically) 


into programs without much modification

  • first support libraries — the original OSes
slide-43
SLIDE 43

1960s: Automatic batch processing

  • to keep up with faster processors, reading and starting/

transitioning between jobs require automation

  • “monitor” programs also keep track of usage, resources

expended, etc.

  • grow to become runtime libraries that automatically manage

the execution of multiple batches of jobs (in sequence)

slide-44
SLIDE 44

Interlude: Pros/Cons of Batch 
 processing?

slide-45
SLIDE 45

1970s: Rise of Timesharing

  • to let many users share a computer concurrently, software is

needed to automatically save/restore context between jobs

  • resources (e.g., CPU & memory) are virtualized
  • jobs are isolated and protected from each other
  • overhead is offset by increased utilization
slide-46
SLIDE 46

1980s: Era of (some) bad ideas

  • Consumer OSes (e.g., MS-DOS, Mac OS) of this era greatly

simplify earlier offerings

  • lack of memory protection
  • cooperative multitasking vs. preemptive multitasking
slide-47
SLIDE 47

1990s-Present: Modern OSes

  • Preemptively multitasked OSes are the norm
  • High degrees of virtualization, isolation, and concurrency
  • Large, sophisticated system call interfaces (e.g., POSIX)
  • Robust, efficient, largely abstracted I/O layer
  • Caveat: lots of OS level overhead!
slide-48
SLIDE 48

Looking Ahead

  • OS-as-library type architectures are making a comeback!
  • Focus on security and robust access to hardware
  • Very little system-level abstraction/virtualization
  • Significantly reduced overhead — any desired abstractions

are provided with user-space libraries