Ch. 16 System software and virtual machines
16.1 Purposes of an operating system (OS)
- Optimise use of computer resources
- Implements process scheduling to ensure efficient CPU use
- Manages main memory usage
- Optimises I/O, dictates whether I/O passes through CPU or not
- Hides the complexities of the hardware
- UI allows users to interact with application programs
- Automatically provides drivers for new devices
- Provides file system, organises physical storage of files on disk
- Provides programming environment, removing the need for knowledge of processor functions
- Provides system calls/APIs, portability
- Kernel
- Part of the operating system
- Central component responsible for communication between hardware, software and memory
- Multitasking
- More than one program can be stored in memory, but only one can have CPU access at any given time
- Rest of the programs remain ready
- Process
- A program being executed which has an associated Process Control Block in memory (a complex data structure containing all data relevant to the execution of a process)
- Process states
- Ready: New process arrived at the memory and the PCB is created
- Blocked: Cannot progress until some event has occurred
- Exit: When the process has finished execution
- Scheduling ensure that the computer system is able to server all requests and obtain a certain quality of service
- Interrupt:
- Causes OS kernel to invoke ISR (Interrupt Service Routine), kernel may have to decide on priority, register values stored in PCB
- Reasons: Errors, waiting for I/O, scheduler halts process
- Low-level scheduling: Allocate processor components to complete specific tasks
Low level scheduling algorithms
- Preemptive: Will stop the process that would have otherwise have continued to execute normally
- First-come-first-served
- FIFO (First In First Out) queue
- Round-robin
- Allocates time slice to each process
- Priority-based
- Priorities re-evaluated on queue change
- Priority calculation requires computation
- Criteria for priority time
- Estimated time of execution
- Estimated remaining time of execution
- Length of time spent in waiting queue
- Paging
- Process split into pages, memory split into frames
- All pages loaded into memory at once
- Virtual memory
- No need for all pages to be in memory
- CPU address space thus larger than physical space
- Address resolved by memory management unit
- Benefits
- Not all of the program has to be in the memory at once
- Large programs can be run with or without large physical memory
- Process
- All pages on disk initially
- More loaded into memory when process ready
- Pages replaced from disk when needed
- Can be done with FIFO queue or usage-statistics based algorithm
- Disk thrashing
- Perpetual loading/unloading of pages due to a page from disk immediately requiring the page it replaced
16.2 OS structure
- OS has to be structured in order to provide a platform for resource management and the provision of facilities for users
- User mode is the one available for the user or an application program
- Privileged/kernel mode has the
16.3 Virtual machine
- Process interacts with software interface provided by the OS
- OS kernel handles interaction with actual host hardware
- Pros
- Allows more than one OS to run on a system
- Allows multiple copies of the same OS
- Cons
- Performance drop from native OS
- Time and effort needed for implementation is high
- Examples and usage
- Used by companies wishing to use the legacy software on newer hardware and server consolidation companies
- Virtualising machines allow developers to test applications on a multitude of systems without having to make expensive hardware purchases
16.4 Translation software
- Lexical analysis: The process of converting a sequence of characters to a sequence of tokens (strings with an assigned meaning)
- Syntax analysis: The process of double-checking the code for grammar mistakes (syntax errors)
- Code generation: The process by which an intermediate code is generated after syntax analysis
- Optimisation: A process in which the code is edited to make improvements in efficiency
- For interpreters:
- Analysis and code generation run for each code line as above
- Each line executed as soon as intermediate code generated
- BNF: Backus-Naur Form
- Can be used as a basis for an algorithm
- Can be defined recursively
| ::= | Defined by |
| | | OR |
| <x> | Meta variable |
- RPN: Reverse Polish Notation
- Used for representing algebraic expressions
- Operator placed after operands