3 - Basic OS (Hardware, Booting, Cache, Kernel) Flashcards
Describe the CPU
The ‘brain’ of the computer
- On board registers for fast computation
- GPRs for data & addresses
- Special Purpose Registers for PC, SP and status register
- FPR etc.
What are the operations for a basic CPU cycle?
Fetch
Decode
Execute
What is the bottleneck of a CPU cycle?
Fetching from memory
What is a solution to the performance hit of fetching from memory?
Pipeline
Caches
What are the advantages and disadvantages of a pipeline?
Benefits: - The cpu can execute more than one instruction at a time - 'hide' the memory access time Cons: - increased complexity
What is a superscaler cpu
Multiple pipelines (Fetch and Decode) feeding into a buffer with multiple execute units at the output
What are 3 ideal memory characteristics?
Fast
Large
Cheap
In practice, we can only ever get 2/3 of these
What is a typical memory hierarchy?
Registers
Cache
Main memory
Disk
What is the typical access time and capacity of registers?
1 nsec
<1KB
What is the typical access time and capacity of caches?
2 nsec
4MB
What is the typical access time and capacity of main memory?
10 nsec
1-8GB
What is the typical access time and capacity of disk?
10 msec
1 - 4TB
Describe main memory
RAM - random access memory
An array of words each with its own unique address
Operations - Load/Store
Slow compared to CPU
What is a Cache?
What is it used for?
Stores the most heavily used data and instructions in fast memory close to core
Goal is to increase performance
Fast but expensive
What is a cache hit?
The data needed by the CPU is in the cache
What is a cache miss?
The CPU needs to fetch the data from main memory
Describe a typical cache hierarchy
L1 (~32KiB) Fastest, private per core
L2 (~0.5MiB) Slower than L1, may be shared by multiple cores
L3 (xMB) Faster than main mem, usually shared by all cores
What are some issues with the concept of a cache?
- when to put a new item into the cache
- which cache line to put the new item in
- which item to remove from the cache when cache is full
- where to put a newly evicted item in the larger memory
- multiple cache synchronization
- how long is the data in cache valid (expiration)
What is memoization?
Similar to caching
Optimization technique used to speed up programs by storing results of expensive computations
What are the two parts of a typical I/O device?
Device Controller
Device
What is the Device Controller?
A chip(s) that physically controls the device Presents a simpler interface to OS
What is a device (For hardware IO)
Connects to computer through controller
Follows some agreed upon standard of communication
What is the Device Driver?
Software that talks to the device controller
Can be implemented as kernel modules and loaded on demand
What is a BUS
A communication system for transferring data between different computer systems
Modern systems have multiple buses
What is Booting? How does it work?
- when the computer is booted, the BIOS is started
(Basic Input Output System) is a program stored on
motherboard - check the RAM, keyboard, other devices by scanning
the ISA and PCI buses - record interrupt levels and I/O addresses of devices, or
configure new ones - determine the boot device (ie. try list of devices stored
in CMOS) - read & run primary boot loader program from first
sector of boot device - read & run secondary boot loader from potentially
another device - read in the OS from the active partition and start it
- OS queries the BIOS to get the configuration
information and initialize all device drivers in the kernel - OS creates a device table, and necessary background
processes, then waits for I/O events
What does BIOS stand for?
Basic Input Output System
What does MBR stand for?
Master Boot Record - is the information in the first sector of any hard disk or diskette that identifies how and where an operating system is located so that it can be boot (loaded) into the computer’s main storage or random access memory.
What does GRUB stand for?
GRand Unified Bootloader
What does the OS do after it has been read in?
OS queries the BIOS to get the configuration
information and initialize all device drivers in the kernel
OS creates a device table, and necessary background
processes, then waits for I/O events
What is the kernel?
‘Heart’ of the OS
Running at all times
Provides services to applications via system calls
Handles all interrupts
Where is the kernel located
Located and started by a bootstrap program (boot loader)
Are application programs part of the OS?
NO
Are system programs part of the OS? The Kernel?
YES
NO
What are the two privilege levels of a CPU?
Kernel mode
User mode
Which register controls the CPU mode?
Status register
What is allowed in Kernel Mode?
- all instructions are allowed
- all I/O operations are allowed
- all memory can be accessed
- note: most of the kernel runs in kernel mode
What is allowed in User Mode?
• only subset of operations are allowed
• eg. accessing the status register is disallowed (of course),
I/O instructions not allowed, access to some parts of memory not
allowed, …
• illegal instructions result in traps (exceptions)
Which applications run in kernel mode?
All of them - System and Application programs
Why would a program want to talk to the kernel?
To do I/O
What is a system call?
A function that a program can call to interact with the operating system
What is a trap?
An exception in a user process. caused by div/0 or invalid memory access or to invoke a system call
When a trap is called what mode is the cpu in?
Kernel mode
Invoking a system call will invoke a trap
True or False?
True
Applications run in user mode.
True or False?
True
Device Drivers run in kernel mode.
True or False?
Both. Usually in kernel mode, but could be user mode as well.