Lecture 3 - Function and Structure Flashcards
How do programs request services from the OS?
Traps or exceptions
How do hardware devices usually request attention from the OS?
Interrupts
What is the fetch execute cycle?
Fetch instruction at program counter
decode and execute
Write results to registers/memory
Increment counter
repeat
What are device drivers?
Routines that interact with specific device types
Encapsulate device-specific knowledge, e.g.
How to initialise device
How to request IO
How to handle interrupts or errors
What two methods can the cpu use to know whether a device is ready/finished?
Polling - device sets flag when it is busy, program tests the flag in a loop waiting for change
Interrupts - when device is ready forces CPU to jump to a specific instruction address
After interrupt is processed CPU returns to previous address and continues execution
How does the storage hierarchy work?
Main memory - large ish storage media - very fast - direct cpu access
Secondary storage - large, slow, no direct access
Speed vs Cost vs Volatility (Pick two)
What is caching?
Copying info into faster storage system
Main memory is fast cache for secondary storage
What is the point of Hardware Protection?
Make sure user programs cannot mess up other programs or OS itself
What is dual mode operation?
Hardware support of differentiating between two modes of operation: user mode (for users)
Kernel mode (for operating system)
How is dual mode operation done at the hardware level?
Mode bit added to indicate current mode (kernel = 0, user = 1)
When interrupt or fault occurs - switch to kernel mode
Priviledged instructions only allowed in kernel mode
All I/O instructions are _______ instructions
privileged
How does memory protection work?
two registers - base register and limit register
base holds smallest legal address for current program
Limit holds size of legal address range for current program
Any attempt to access outside this is refused
Kernel mode can access any mem
The load instructions for base and limit registers are ____________ instructions
privileged
What is CPU protection?
Timer - interrupts control after specified period to ensure OS maintains control
Prevents program going into infinite loop and stopping OS from running
Timer also used to implement timesharing
Timer operations are privileged instructions
What is a system call?
When a program needs a service from the OS
Passes relevant info to OS
OS performs the service if it is permitted for the program
OS checks to ensure info passed to it is ok
What sort of operations can system calls do?
Fork program
Replace process’ core image
Terminate program
Read/write to I/O devices
Change file permissions
Etc.
What is the booting process for an OS?
Bootstrap program loaded from ROM
Runs loader program
Which loads and runs kernel
Which loads and runs rest of os
What is the difference between simple and layered OS?
Simple: Only one or two layers of code
Layered: Several levels, lower independent of upper
What is the difference between a monolithic kernel and a microkernel?
Monolithic: OS is a single, large system that does all OS related activities
MicroKernel: OS is built from many small user level processes
What are the 7 layers of a layered OS?
User Programs
Interface Primitives
Device Drivers and Schedulers
Virtual Memory
I/o
Scheduling
Hardware
In a layered OS, each layer uses functions and services of only _____________________ layers
Lower level
What are some of the problems with layering?
Imposes hierarchical structure which might not be appropriate (e.g. file system requires virtual memory buffer, virtual memory might want a file system for backing store) - not flexible
Poor performance - crossing each layer involves overhead
Not realistic - modeled as layers but systems aren’t actually built that way
In the traditional unix system structure, what is the “boundary” between kernel space and user space?
System call interface - everything strictly below this is kernel space
What does a microkernel approach aim to do?
Move as much as possible into user space, just a very small core OS
Communication between modules with message passing
What are the benefits and disadvantages of a microkernel approach?
Benefits: more portable OS
Easier to extend kernel
More reliable (less running in kernel space)
Individual bits of kernel protected from each other
Disadvantages:
Big performance overhead from message passing between modules
What is the client-server architecture of microkernels?
Process don’t share memory
Communication using message passing
Processes can request services from other processes
In a microkernel, the file system, network, thread management, scheduling and paging would all be part of _______________ which are in _________ mode
System processes
User mode
What is the difference between module bases structure and layered structure?
Layered: inflexible
Modules: no layers, rather individual system modules communicate using known interfaces through the core kernel
What does a virtual machine do?
Emulates an entire operating system plus hardware etc. in software
Illusion of multiple processes each with its own processor and virtual memory
What is a Type 1 Hypervisor?
Hypervisor directly on top of hardware - hosts many guests.
No Host OS - more efficient
What is a Type 2 Hypervisor?
Hypervisor runs in a Host OS and hosts guests
Host OS on top of hardware