Title: Operating systems
1Operating systems
2Administrivia
- Report on the midterm
- Lab 5 (or is it Lab 7?)
- Need a CD and headphones
- Problem set schedule
- Duplicating homework not recommended
3Grades on Midterm
4Midterm Grades
Calculated very pessimistically
5Difficulties
- 1b) If your computer has 256 megabytes (MB) of
RAM, how many bits are needed to be able to
address all of the bytes of that memory? How
does this number change if we organize bytes into
words that are groups of 4 bytes (32 bits) and
only need to be able to address individual words,
not individual bytes? - 2c) Give a truth table for the black box weve
described here. You do not need to draw any
logic gates.
2d) How could you use multiple
copies of the black box from part c) to build a
circuit that does subtraction of 4 bits numbers? - 3a) Draw the state diagram describing this State
Machine. Clearly label the arrows between states
of your state machine. Dont forget to include
arrows from a state back to itself if it should
stay in the same state. Make sure your diagram
is complete.
6Addressing Memory
7Truth table
8Black box
9State machine
- Have to remember last input (2 bits)
- Have to create output
10State machine (cont.)
11Homework schedule
- Assignment 5 due next Tuesday (11/13)
steganography - Assignment 6 due 11/20 file system design
12Lab schedule
- Week of 11/5 Audio
- Week of 11/12 Visual Basic 1
- Week of 11/19 No Lab
- Week of 11/26 Visual Basic 2
- Week of 12/3 Spreadsheets
- Week of 12/10 No Lab
13Where we are
- Built a computer
- 0s and 1s and representations
- logic gates to compute on 0s and 1s
- circuits of logic gates to realize truth tables
- state machines (special purpose computers)
- general purpose computer (programmable)
14Whats next
- Figure out what it takes to use computer
- Work from our experience
- Work top down as well as bottom up
- Identify tasks and see how they are done
- Understand pieces of the operating system
- Attach computers to build network of computers
- for communication (InterNet)
- for computing (Seti_at_home, cancer cure)
- for file sharing (Napster, Gnutella, Kaaza)
- Program computers
- Visual basic
- Explore underpinnings
- Theory
- Legal
- Intelligence
15Lecture plan
- Week of 11/5
- Operating system
- Networking
- Week of 11/12
- Programming
- Week of 11/19
- Distributed computing
- Week of 11/26
- Algorithms
- Unsolvable problems
- Week of 12/3
- Encryption
- Digital Rights Management
- Week of 12/10
- Aritificial Intelligence
- Review
16Lecture plan
- Week of 11/5
- Operating system (How Windows works)
- Networking (How the internet works)
- Week of 11/12
- Programming (Making the computer do
different things) - Week of 11/19
- Distributed computing (How Kaaza, Seti_at_Home
work) - Week of 11/26
- Algorithms (How Google works)
- Unsolvable problems
- Week of 12/3
- Encryption (Why you can email your credit card
) - Digital Rights Management (Legal issues)
- Week of 12/10
- Aritificial Intelligence (Replacing ourselves by
machines?) - Review
17User experience at the computer
- You turn it on
- System boots
- First the hardware, then the Windows operating
system - Your desktop appears
- First icons, then applications
- Interaction devices can be used
- Machine is listening to mouse, keyboard, etc.
- Machine enters new version of the fetch/execute
cycle - Machine fetches command from user
- Machine executes commands
18What happens when machine boots
- Power goes on, each device is turned on
- BIOS lets you talk to hardware
- Change order devices are turned on
- Set system clock
- Identify new interaction devices
- Then, the boot program for Windows starts.
- You tell it an order to look at disks
- It looks at disks in this order to find operating
system - Operating system boots
- Simple program called the operating system kernel
is loaded (at location 10). This is the program
that runs the computer.
19Operating system kernel
- Kernel
- Starts
- Device drivers
- Talk to RAM, disks, CD/ROM,
- Starts subsystems
- memory management system (to organize data on
RAM) - file system (to organize files on disk)
- Gets user started
- Starts window manager or creates a shell
- Starts fetch/execute cycle
20Fetch/execute cycle
- Fetch is Event driven
- Execution is done by the operating system
21Fetching
- Fetch is Event driven
- The window manager listens for an event
- From keyboard
- Key down/key up
- From mouse
- Mouse motion, mouse button up or down
- From other device
- Game controller
- Speech interface
22Fetching (cont.)
- Identify where the command occurred
- In which window on the screen
- Identify the action that must be taken
- Examples
- Type text into Word window
- Click command in window of executing program
- Click on resize corner of window
- Click on icon from window
- Click on icon from task bar
23Parsing commands
- Type text into Word window
- Text is passed to Word program
- Click command in window of executing program
- Command is passed to executing program
- Click on resize corner of window
- Window manager
- Listens to mouse for stretching
- changes the geometry of the screen
- The application might tell the window manager how
- Click on icon from window
- Action to be taken is identified
- Click on icon from task bar
- Sleepy program comes back to life
24Parsing commands
- Possibilities
- Pass information to an existing command
- Type text into Word window
- Click command in window of executing program
- Start new command
- Click on icon from window
- Wake up existing command
- Click on icon from task bar
- Modify the geometry of the display
- Click on resize corner of window
25Executing existing commands
- Type text into Word window
- Text is passed to Word program
- Word program has previously been put into RAM.
It is storing the text in space it has in RAM, so
the new text is added to that RAM. - Von Neumann model
- How is RAM managed?
- What if you need more
- What if you overflow your memory?
- What happens when you quit?
26Starting new command
- Have to identify the command
- How to start Word
- Select Word from the Start menu
- Click on icon for Word
- Click on a shortcut to the icon for Word
- Click on a file called Something.doc
- Click on an unidentified file and tell it to use
word to open - Enter from a command line
27Starting new command (cont.)
- Click on a file called Something.doc
- Windows registry keeps track of such things
- File associations
- .doc Word
- .jpg Default Image viewer
- .vbs Visual Basic
- .mp3 .wav etc. various music formats
- A newly installed program may change file
associations
28Sidebar on file associations
- AnnaKournakova.jpg.vbs
- what is it?
29Sidebar on file associations
- AnnaKournakova.jpg.vbs
- what is it?
- It comes as an attachment
- mailer opens it with Visual Basic
- It executes
30Sidebar on file associations
- AnnaKournakova.jpg.vbs
- what is it?
- It comes as an attachment
- mailer opens it with Visual Basic
- It executes
- What it does
- Open your address book
- Package itself as a message
- Sends itself to everyone you know
31Starting new command (cont.)
- Once the command is found
- C\Program Files\Microsoft Office\Office\WinWord.e
xe - Locate the command on the disk
- Move the command to RAM
- Add it to the list of commands being executed
- Let it run
- How do you find it on disk?
- How do you know where to load it in RAM?
- How do you keep track of all running programs?
32Starting new command
- Have to identify the command
- How to start Word
- Enter from a command line
- StartgtRungt
- C\Program Files\Microsoft Office\Office\WinWord.
exe - Icons are just an improved User Interface
- In UNIX, use keyboard to create the command line
- In Windows, use mouse to click on icons.
33The Window Manager
- Maintains the geometry
- Identifies events with windows
- Confusion
- Windows 95, 98, NT, Me, 2000 is the operating
system - Underneath runs the window manager
- How does the window manager work?
34Unresolved questions
- How is RAM managed?
- How do you find it on disk?
- How do you know where to load it in RAM?
- How do you keep track of all running programs?
- How does the window manager work?
- Answer
- This is what the operating system does
35Operating system
- Its kernel is what starts at boot time
- Contains memory manager for RAM
- Contains file system to manage disk
- Contains process manager to control running
programs - Runs the window manager
- Contains the device drivers for running devices
updates as necessary (plug and play)
36The ideal operating system
- Never stops
- Uses no resources
- Is easy to modify and update
- Has no security holes and no bugs
37The ideal operating system
- Never stops
- If every process forgets a little data (1KB/s)
machine will crash within a few days - Uses no resources
- It shouldnt be a drain to run it
- Is easy to modify and update
- New devices come out,
- Has no security holes and no bugs
- But these are complex programs.
- IBM joke ?
- Microsoft joke ?
38Managing memory
- Initially
- Some space reserved for the operating system
- Rest of space for user programs
- When a new program starts
- Gets space for execution
- Gets space for data
- As a program executes
- Can ask for more space
- Can free up space
- When a program stops
- Its memory is released
39Memory management
Op. Sys
Initially
40Memory management
Op. Sys
Op. Sys
Initially Start Word
Word.exe
Word data
41Memory management
Op. Sys
Op. Sys
Initially Start Word Word needs More memory
Word.exe
Word data
Word data2
42Memory management
Op. Sys
Op. Sys
Op. Sys
Initially Start Word Word needs More
memory Start IE
Word.exe
Word.exe
Word data
Word data
Word data2
Word data2
IE
43Memory management
Op. Sys
Op. Sys
Op. Sys
Initially Start Word Word needs more
memory Start IE Word needs more memory
Word.exe
Word.exe
Word data
Word data
Word data2
Word data2
IE
Word data3
44Memory management
Op. Sys
Op. Sys
Op. Sys
Initially Start Word Word needs more
memory Start IE Word needs more memory Exit IE
Word.exe
Word.exe
Word data
Word data
Word data2
Word data2
Free Space
IE
Word data3
Word data3
45Memory management
Initially Start Word Word needs more
memory Start IE Word needs more memory Exit
IE Word frees space
Op. Sys
Op. Sys
Op. Sys
Word.exe
Word.exe
Free space
Word data
Word data2
Word data2
Free Space
Free Space
Word data3
Word data3
46What if you run out of memory?
- Use virtual memory
- Have some memory in RAM, some in disk
- Hide the details from the user
- Make choices effectively
- paging
47Virtual memory
- User thinks the machine has 512 MB of RAM
- 256 MB are in RAM
- 256 MB are on disk
- Memory mapper works in units of pages
- A page may be on disk or in RAM
- Common pages are on RAM
- Page must be moved to RAM to be used
- Disk is just a staging area
- When request comes for information
- Memory mapper finds page
- If in RAM, things proceed
- If on disk, must clear space in RAM and move it
there
48Virtual memory (cont.)
- When request comes for information
- Memory mapper finds page
- If in RAM, things proceed
- If on disk, must clear space in RAM and move it
there - What to clear?
- LRU least recently used page
49Virtual Memory
Op. Sys
Word.exe
Word data
Word data2
IE
IE data
50Virtual Memory
Op. Sys
Word wants more space
Word.exe
Word data
Word data2
IE
IE data
51Virtual Memory
Other IE data
Op. Sys
Word.exe
Memory mapper
Word data
Word data2
Requests for memory go through the memory mapper
which finds the needed pages
IE
Some IE data
Word data3
Virtual memory on disk
52Sidebar on speed
- Difference between register, RAM, disk
- Registers are right there can access right away
- RAM requires
- a request onto the bus
- Address decoding
- Returning data on the bus
- Disk requires
- Request onto the bus
- Determining where data is on disk
- Spinning disk platter to get there
- Gathering data, putting it on the bus.
53Jim Gray
54The File system
- How does the disk work?
- How do we organize files?
- Whats in a name
- Is a text file different from an executable or a
folder?
55Disk
- Controller
- Electronics that run the disk
- Communicate on the bus
- Disk itself is
- Platters
- Arms to read off of platters
- Disk spins at 3600 or 7200 RPM
- Arms read/write data at appropriate part of
platter - Might have 3 platters, 6 read/write arms
56Platters
Sectors pie shaped wedges Tracks concentric
circles
Low-level formatting establishes the tracks and
sectors on the platter. This process prepares
the drive to hold blocks of bytes. High-level
formatting then writes the file-storage
structures, into the sectors. This process
prepares the drive to hold files. The file
system (part of the operating system) determines
which file-storage sectors will hold which files.
57File System
- There is a top level object called Desktop
- An object can either be a file or a folder
- object knows
- File or folder?
- Number of blocks
- Location of first block (on physical disk)
- Block keeps track of next/previous block
- Modification information
- Sharing information
- Any user supplied information
58File system (cont.)
- File
- First block stores data
- Points to block of next data
- Folder
- First block stores names of objects it holds
- For each, it stores
- System given name
- Location of first block
59(No Transcript)
60Processes
- Any program that is executed is a process
- Process state gives current status of process
- Value of program counter (as a register)
- And other registers
- And memory
- One program can lead to multiple processes
61Controlling processes
- Process table
- One entry for process
- Is it ready
- Is it waiting (e.g. for device)
- Dispatcher
- Does process switching
- Causes an interrupt
- Process may cause its own interrupt
62Twists and turns
- Fair scheduling
- Each process gets its time slice if needed
- But might want to be able to assign priorities
- Deadlock prevention
- Process A needs printer and CD to continue
- If gets assigned the printer
- Process B needs printer and CD to continue
- It gets assigned the CD
- How do things continue?
63A look at existing operating systems
- Windows
- 95, 98, NT, 2000, Me, XP
- Linux
- Public domain UNIX
- MacOS
- MacOS 7 was far ahead (1992)
- MAC OS X trying to catch up (2001)
- Solaris
- Larger server world
64Linux
WHAT IS LINUX? Linux is a Unix clone written
from scratch by Linus Torvalds with assistance
from a loosely-knit team of hackers across the
Net. It has all the features you would expect
in a modern fully-fledged Unix, including true
multitasking, virtual memory, shared libraries,
demand loading, shared copy-on-write executables,
proper memory management and TCP/IP networking.
It is distributed under the GNU General
Public License. (open source source code is
free)
65Linux -- where does the work go
66Why is it hard to build an operating system?
- Theyre big
- Parts of them are driven by need for efficiency
- Need to be backwards compatible
- Must control many devices not built here
67Operating systems respond to computer systems
- Brief history
- Single task
- Time sharing
- Multitasking
- Ubiquitous computing
68Computing in the 1940s/50s
- Single processor/Single task
- Turn on the machine
- Do the task
- Do the next task
- .
- Turn off the machine
- Tasks had time limits because computing was
expensive.
69Computing in 1960s/1970s
- Time sharing
- One machine, many tasks
- Each task gets 1 jiffy ( 1/60 second)
- During its time slice
- Task (and its data) would be swapped in
- Task would operate for its time
- Task (and its data) would be swapped out
- Many users could be serviced at once
- More efficient (why??)
70Computing in the 1980s
- Multiprocessing/multitasking
- Machine can do more than one thing at a time
- Like timesharing but has many users processed at
once (or such is the illusion)
71Computing in the 90s
- We compute on true multiprocessors
- 1 box with multiple processors
- Multiple machines connected by a network
- New challenges
- Load balancing keep each processor busy
- Scaling breaking tasks across many machines
72Computing in the 00s
- Everything is its own computer
- Computers communicate and work together
- Java/JINI languages to support this
- Light weight processes
- Everything means everything
- Toaster, heater, sound system,
- House of the future