Lecture 4
Lecture 4
• The OS is a program
– Permit easy access, control hardware, communicate between user
and software, user and hardware, software and hardware, maintain
the computer system (hardware and software)
– Users can access the OS via GUI and command line
• Kernel
– Always resident in memory
– Responsible for primary OS tasks (process management, memory
management, resource management, protection, security)
• Device drivers
– Program interfaces between OS and peripheral devices
• Shell
– User interface, tailorable
• Utility programs
– Add on programs to further manage and fine-tune your system
Interrupts
• The CPU’s fetch-execute cycle runs continuously
unless interrupted
– Interruptions can come from hardware or the running
program
• control+alt+delete
• mouse moved
• printer out of paper
• program has run-time error
– An interrupt interrupts the CPU at the end of fetch-execute
cycle
– Upon interrupt, CPU determines what device (or user or
software) raised interrupt
• select the proper interrupt handler (piece of OS code)
• execute interrupt handler to handle the interrupt
User Interface
• GUI
– Point and click, drag, double click
– Touch screen devices use gesture-based motions (swiping,
tapping, pinching, reverse pinching)
• Command line
– Enter commands from a command line prompt
– Commands executed by an interpreter
• breaks instructions into component parts
• converts instructions to machine code and executes them
• maintains a “session”
• we examine the Bash interpreter in chapter 9
– Commands may look cryptic and be hard to learn but offer
more power and flexibility
• Linux command: find ~ -name ‘core*’ –exec rm {} \;
Process Management and Scheduling
• Process – a running program
– Processes have a status (running, ready, waiting, stopped)
– And data (stored in memory, cache, registers)
• Process management is how the OS handles the tasks of
starting processes, managing running processes,
performing interprocess communication, terminating
processes
• Another aspect is process scheduling – selecting the next
process to run
• Scheduling algorithms include round robin, priority, first
come first serve, shortest job first, longest job first
• Processes wait in queues
– Waiting queue – waiting to be loaded into memory
– Ready queue – in memory, but not currently executing by the CPU
Memory Management
• We may not be able to fit all of our running program(s) in memory
– We use swap space as “backing storage”
– Swap space is placed on the hard disk
• We break our programs into fixed sized units called pages
– The OS moves pages for us between swap space and memory as needed
(on demand)
• This is known as virtual memory
• Program broken into fixed sized pages
– Memory broken into fixed sized frames
• when process begins running, first pages are moved to available frames
• OS maintains page table
– CPU generates a memory address:
• page #, position on page
– Use page table to translate this to physical address
• frame #, position on frame
– If page not in memory, page fault occurs
Virtual Memory: Paging and
Page Tables
Process A page table
Page Frame Valid
0 1 T
1 - F
2 - F
3 3 T
4 0 T