Computers and the Internet Flashcards
When may polling be preferable?
Polling may be efficient if:
- The controller and the device are fast
- The I/O rate is high
- Some I/O data can be ignored
- The CPU has nothing better to do
Explain Large Data Transfers in Devices
-Some devices (e.g., disk drives) will often do large data transfers
-The transfer will be inefficient if the CPU has to feed data, byte by
byte, to the controller’s registers
- A better approach is to offload this work to a special-purpose
processor (a direct memory access (DMA) controller)
What are device drivers?
A device driver hides differences between various device controllers by defining an interface between the OS and I/O devices for a specific class of I/O devices.
What is Direct Memory Access?
-The CPU writes command block into memory, specifying source and destination of transfer
-The DMA controller can then perform multiple transfers via a single command
-When the transfer is complete, the CPU receives an interrupt from the DMA controller
-This enables the CPU to spend more resources on other tasks
What are System Calls?
A request of a kernel service.
What is a Character I/O
(Examples: keyboards, computer mice, microphones, speakers)
- A character device transfers byte one by one
- Characters must be processed in order that they arrive in the
stream
What does Character I/O interface include?
The interface includes
- Get operation, to return the next character in the stream
- Put operation, to add character to stream
- Libraries for line-by-line access, with integrated editing services (e.g.,
use back spaces to remove the preceding character from the
stream)
What is Block I/O?
Block devices (typically non-volatile mass storage devices) are used to transfer blocks of data.
They are high volume devices
What does Block I/O interface include?
The interface includes:
- Read operation, for reading blocks of data
- Write operation, for writing blocks of data
How does does Block I/O access Memory-Mapped Files?
Layered on top of block device drivers
Rather read/write, it provides access to disk storage via a location in main memory
The OS deals with transferring data between memory and the device and can perform transfers when needed
What does a network socket interface have system calls for?
- Creating and connecting sockets
- Sending and receiving packets over the connection
- Select function, for determining the status of one or more sockets
(whether the socket is ready for reading or writing )
What is the main difference between network I/O device and other I/O devices?
With network I/O devices things routinely go wrong (missing packets, etc.)
Therefore, there need to be a system functions for:
- Checking whether a transfer was successful
- Recovering gracefully from unsuccessful transfers
Define a program
A set of instructions for performing a specific task and is stored on a disk (passive)
Define a process
An instance of a program, in execution (active) - requires CPU resources, memory and I/O
Multiple process instances of one program
Why use processes?
Modularity:
- Simplifies OS development and maintenance
Speedup through Parallelism:
- Execute multiple processes in parallel using multiple CPU cores
Security and Stability through Isolation:
- Usually, each process operates in its own memory space
- Minimize inter-process disruptions – problems in a process may not
affect others
What is a Process Control Block (PCB) ?
A PCB is a data structures that stores all the information about a process
- Kernel’s representation of a process
How does Context Switching work?
Stop running process 1 and start process 2:
- Change the state of process 1 from running to ready
- Save the context of process 1
- Load the context of process 2
- Change the process scheduling state of process 2
What is the tradeoff of Context Switches?
With too few context switches
- No fairness between processes – some processes may have to wait for a long time
With too many context switches
- The processor will spend too much resources on overhead
Key info about the stack structure
LIFO structure
Operations: Push and Pop
Function Call: Activation record (parameters, local variables, return address) pushed to stack
Function Return: Activation record popped from stack
Key info about the heap structure
- Dynamically allocated like the stack
- Blocks of memory are allocated and removed in an arbitrary order
Used when you need:
- To store a large block of memory for a longer period of time
- Variables that can change size dynamically
What is Process Hierarchy?
In Unix-like systems there is a hierarchy of processes
What is process spawning?
The method by which a process (parent) creates a new process (child)
- In linux there are 4 system calls for process spawning:
- fork()
- wait()
- exec()
- exit()
Define a Preliminary
- A process is a program in execution
-Processes change their state over the process lifecycle
What is a process scheduler?
Process schedular allocates CPU time to various processes
What are 4 scheduling algorithms?
First Come First Served (FCFS)
Round Robin (RR)
Shortest Process Next (SPN)
Multilevel Queing
What is the key info of a FCFS?
FIFO - Processes get executed in order arrived
Non-preemptive - Not interrupted until finshes or reaches a wait state
What are the Pros and Cons of FCFS?
Pros:
1. Simple and easy to implement
2. Reduced Context Switching
3. Intuitively fair
4.No starvation
Cons
1. Convoy Effect - Long waiting time and poor responsiveness
What is the key info of a Round Robin?
Time-sliced (quantum) FIFO execution
Preemptive
What are the pros and cons of the Round Robin
Pros:
Fair CPU Allocation
Responsiveness
No Starvation
Cons:
Time Quantum Sensitivity
Context Switch Overhead
What is the key info of a SPN?
Select the process with the shortest execution time
Non-Preemptive – Preemptive (Shortest Remaining Time)
What are the pros and cons of the SPN?
Pros:
Better average waiting time
Responsiveness
Cons:
Estimating process execution time
May lead to starvation
Longer processes wait longer
What are the pros and cons of Multi-level Queuing?
Pros:
Supports different performance objectives
Cons:
Complex and difficult to calibrate
What is Multi-level Queueing?
- Processes are divided into different queues based on their priority and characteristics.
- Each queue has its own scheduling algorithm.
- Improves efficiency by grouping similar processes and handling them with specialized algorithms.
( Commonly used to manage and prioritize different types of processes, such as interactive and batch processes )
What is a multi-core processor?
- A multi-core processor has multiple processing units (cores) on a
single CPU chip - Each processor/core has its own L1 cache memory
- There is a cache hierarchy
What are the two types of efficient Multi-Processor Scheduling?
Load Balancing
Processor Affinity
What is Load Balancing?
Evenly distribute processes among CPU cores
What is Processor Affinity and Soft Affinity
Processor Affinity: Keep a process on the same CPU core(s)
Soft Affinity: Only move processes if there is a good reason
What is Monoprogramming?
Single Process
What is Multiprogramming?
Multiple Processes
What are the 3 memory Management Tasks?
- Relocation
- Protection
- Sharing
Define Relocation
Moving a process to a new location in memory without disrupting its execution
Define Protection
User processes need to protected from each other
System processes should be protected from user’s processes
Define Sharing
Processes may sometimes need to share data
What are the 6 Memory Management Techniques
- Fixed Partitioning
- Dynamic Partitioning
- Simple Segmentation
- Virtual Memory Segmentation
- Simple Paging
- Virtual Memory Paging
What is the key info on Fixed/Static Partitioning?
Memory divided into partitions of fixed boundaries (equal or unequal sizes)
1-to-1 mapping of partitions and processes
Process loaded into partitions ≥ its size
What are the pros and cons of Fixed Partitioning?
Pros:
Easy to uunderstand and implement
No external fragmentation
Cons:
Internal Fragmentation
Limited by number & size of partitions
What is the key info of Dynamic Partitioning?
Exact memory allocation – only what is needed
- Partitions of variable length and number
- 1-to-1 mapping
Starts well, then leads to external fragmentation
Define External Fragmentation
Space is wasted between partitions
Define Compaction
Shift processes for unified free memory space
What are the pros and cons of Dynamic Partitioning?
Pros:
No internal fragmentation
Efficient than static partitioning
Cons:
External fragmentation
Overhead of compaction
What is the key info of Single Segmentation?
Processes divided into segments
Segments are loaded into memory as in partitioning
Segments do not need to be contiguous
What is the key info of Virtual Memory Segmentation?
Virtual memory use disk space to extend main memory; illusion of larger memory
Segments can be swapped between memory and disk storage
OS loads segments into memory as needed
What are the pros and cons of Virtual Memory Segmentation?
Pros
Can fit processes larger than memory
Segment Sharing and Protection
No internal fragmentation
Efficient than static partitioning
Cons:
More complex memory management
External fragmentation (< dynamic)
Overhead of compaction
What is the key info of Simple Paging?
Memory divided into equal size frames
A process is divided into same-size pages
Internal fragmentation is small since:
- only affects the last frame of each process
- the frame/page-size is fairly small
What are the pros and cons of Simple Paging?
Pros:
No External Fragmentation
Simple memory allocation
Cons:
Small Internal Fragmentation
Page tables can become large
What is Virtual Memory Paging
Pages are loaded into frames as in simple paging, except, that not all the pages need to be loaded at the same time
What are the pros and cons of Virtual Memory Paging?
Pros:
Can fit processes larger than memory
No external fragmentation
Simple memory allocation
Cons:
Virtual Memory overhead
Small Internal fragmentation
Page tables can become large
What are the goals of Protection & Sharing (with Segmentation and Paging) ?
Protection: Each process can only access its own pages/segments
Sharing: Multiple processes can access the same page/segment
How is Protection & Sharing implemented (with Segmentation and Paging) ?
Each frame/segment has a number of protection bits specifying
Read, write, execute permissions, which processes have these permissions
What is the result of Protection & Sharing when using segmentation instead of paging?
Protection/sharing is generally easier with segmentation than paging since:
- Segment table is smaller than page table
- Segments are more natural units for protection/sharing
How do Positional Numeral Systems work?
The contribution of a digit to the value of a number is the value of the digit multiplied by a factor determined by the position of the digit
What is the key info for the octal system?
Base 8
Easier shorthand for binary
An octal represents 3 bits.
What is the Memory Hierarchy?
Speed (Top to bottom):
Registers
Cache
Main Memory
Disk
Size (Top to bottom):
Disks
Main Memory
Cache
Registers
What are the main components of a computer?
- Disk Controller
- USB Controller
- Graphics Controller
- CPU
- Memory
What is the key info of the CPU?
Controls the execution of instructions
A CPU will use a specific instruction set architecture (ISA), such as ARM or x86
Define a register
Small, fast memory locations within the CPU
What are the different types of registers?
- General purpose registers: data storage, address calculations and
arithmetic operations - Special purpose registers: Program counter, Base pointer, Stack
pointer, Link register, Current program status register
How does the Stack pointer work?
Points to the top of the stack
How does the Base pointer work?
Points to the start (base) of the current frame
How does the Link Register work?
Stores the return address for after function completion
How does the program counter work?
Stores the address of the next instruction to be executed
How does the ALU work?
Handles arithmetic and logical operations
What does the current program status register do?
Contains status and mode bits
What is assembly language?
Simple instructions
Difficult programming language
What is branching?
Branch instructions will “jump” to a different instruction
They do so by changing the program counter
What is Temporal Locality?
Items accessed recently are likely to be accessed again soon
- Example: loops
If you want to discard data, start with one that has not been request in a long time
What is Spacial Locality?
Items located near each other in memory are likely to be accessed within a short period of time
- Most programs exhibit spatial locality
Copy additional nearby memory locations into the cache
What are Hits and Misses?
A memory request may be a:
- Cache hit – the cache contains the data (faster data return)
- Cache miss – the cache does not contain the requested data – first
read from memory
What are the 3 Cache Designs?
- Direct Mapping
- Fully-associative Mapping
- Set-associative Mapping
What is the key info of a Directed-Mapped Cache?
Each block of main memory maps to one unique cache line
Each line connects the connects the corresponding block of cache memory to each block of main memory
What are the pros and cons of a Directed-Mapped Cache?
Pros:
Simple, Easy to implement & search
Cons:
Inefficient use of the cache space
What is the key info of a Fully-Associative Cache?
Each block of main memory can map to any line of the cache
Replacement algorithm: LRU (Least Recently Used)
What are the pros and cons of a Fully-Associative Cache?
Pros:
Flexible
Cons:
Takes a long time to search
What is the S-Way Set-Associative Cache
The cache is divided into N cache sets
Each cache set consists of S lines
Each block of main memory maps to one unique cache set
Replacement algorithm: LRU (Least Recently Used)
What are write hits and write misses?
A write request may be a:
- Write hit – the address we want to write to is present in the cache
- Write miss – the address we want to write to is not present in the
cache
How would you deal with a Write Hit?
For a write hit, there are two options:
- Write-back – initially write only to cache
- Write into memory if being replaced
- Pros: fast writes
- Cons: mechanism for cache coherence
- Write-through – write into both cache and memory
- Pros: consistency between the cache and memory
- Cons: slow writes
How would you deal with a Write Miss?
For a write miss, there are two options:
- Write around (no-write allocate) - write into memory only
- Pros: Avoids unnecessary cache access and cache pollution
- Cons: Does not utilize temporal locality
- Write allocate – fetch from memory and write into cache
- Pros: exploits spatial and temporal locality
- Cons: Potential unnecessary cache access and cache pollution
Whats the result of a High Temporal Locality and a Low Temporal Locality?
High Temporal Locality: Write-Back + Write Allocate
Low Temporal Locality: Write-Through + Write Around
What is Virtual Memory?
Use disk storage as if it was main memory
Define Demand Paging
Only load a page when there is a request for it
What are the pros and cons of Demand Paging?
Pros:
More processes can be loaded into main memory
Cons:
Thrashing - the CPU spends too much time on swapping pages
Define Pre-Paging
Guess which pages will be requested and pre-load them
What are the pros and cons of Pre Paging?
Pros:
Less overhead when page predictions are accurate
Cons:
Resources are wasted on loading unused pages