Week 2 Flashcards
What are I/O devices?
allows humans or devices to communicate with computers
What are examples of I/O devices?
Human interface devices: keyboard, mouse, monitor, speaker and printer, game controllers
Storage Devices: HDD’s, SSD’s, USB flash devices
Communication devices: network interface cards
What is a bus used for with I/O devices?
The communication with I/O devices is performed over a bus
What are controllers used for with I/O devices?
The I/O devices are operated using controllers
How does the processor communicate with a controller?
The processor communicates with the controller by reading and writing to the controller’s registers
What are the 4 controller registers?
Data register - temporal storage of data
data-in register - data coming from device
Status register - indicating status of device
Control register - commands to device
What is a Port-mapped I/O (PMIO)?
Isolated
A separate IO address space
CPU uses special IO instructions to access IO devices
What is a Memory-mapped I/O (MMIO)?
Device registers are treated as part of memory space
CPU access registers using standard memory instructions
What are the 2 I/O Control Methods?
Polling
Interrupts
What is Polling (SR)?
CPU repeatedly checks the status register to see if it needs attention
What is an example of Polling?
Writing to a disk
CPU repeatedly checks the status register to determine if disk is ready
If status is ready, CPU can write to the data-out register
Once the write operation is complete, the disk controller updates the status register
What are interrupts?
a signal from an I/O device to notify CPU it requires attention
CPU temporarily halts it current progress
Performs necessary action then resumes previous task
When may polling be preferable?
If controller and device are fast
I/O rate is high
Some I/O data can be ignored
CPU has nothing better to do
How are large data transfers done on devices?
Offloading this work to a special purpose processor (DMA controller)
What is a DMA controller (Direct memory access)?
DMA allows IO devices to bypass CPU and directly read/write from/to memory
Enables CPU to spend more resources on other tasks
What is a Device Driver?
Lets the OS and a device communicate
Hides differences between various device controllers by defining interface between OS and I/O devices for specific class of I/O devices
What is a character device + examples?
transfers bytes one by one
examples: keyboards, computer mice, microphones, speakers
What does the character I/O interface include?
get - read()
put - write()
other operations, line by line access ,seek ,editing services (eg. backspace)
What are Block I/Os + examples?
Block devices handle I/O in blocks (chunks) of data
examples: HDD, SSD, CD-ROM, and DVD drives
Usually high volume devices
What does the Block I/O interface include?
read - reading blocks of data
write - writing blocks of data
What do Network I/O’s do?
sending and receiving packets over the connection
What is the main difference between network I/Os and other I/O devices?
things routinely go wrong (missing packets etc.)
Therefore there need to be system functions for:
Checking whether data transfer was successful
recovering gracefully from unsuccessful transfers
What is a Program?
A set of instructions for performing a specific task (passive)
Stored on disk
What is a Process?
Instance of a program in execution (active)
Requires CPU resources, memory and I/O
There can be multiple process instances of one program
What are the benefits of 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)?
Each process is represented by a PCB
A PCB is a data structure that stores all info about a process
PCB is the kernels representation of a process
What is context switching?
Stop running process 1 and start process 2
- Change the state of process 1 from running to ready
- Save the context of process 1
- Save the context of process 2
- Change process scheduling state of process 2
Whats 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
Aim : Optimise the number of context switches so that:
No process is waiting too long
Associated overhead does not slow down performance
What are the properties of The Stack and its operations?
Data Structure - LIFO (Last in first out)
Operations:
Push - adding to stack
Pop - removing from the stack
Function call: Activation record (parameters, local variables, return address) pushed to stack
Function return: Activation record popped from stack
What are the properties of The Heap?
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 spawning?
Method by which a process (parent) creates a new process (child)
In Linux there are four system calls for process spawning
What is a Fork? (Part of process spawning)
Fork creates a child process with unique process ID
Child is a copy of the parent process
For returns:
0 to child process
Process ID of the child process to the parent process
What is a Exec? (Part of process spawning)
Replaces the program executed by a process
What is a Wait? (Part of process spawning)
Parent process is put in waiting state until child process finishes
What is an Exit? (Part of process spawning)
When done, child process issues the exit system call, and the parent process can resume
What is Interprocess Communication (Share data)?
Processes may need to share data with each other
Examples:
Multiples processes interested in same info
Subdivide a process into multiple subtasks that are solved simultaneously
What are the 2 ways Interprocess Communication can be implemented?
- Shared memory
- Message passing
What is Shared Memory?
Memory space is shared between 2 processes
To communicate processes read or write into shared region
Establishment of shared memory typically requires system calls
Processes have to manage simultaneous access to same memory space
What is Message Passing?
Processes communicate by sending messages to each other
The messages are sent to/received from an agreed “mailbox” that is not part of the address space of any of the processes
What are the pros of Shared Memory?
Faster than Message Parsing
Message parsing systems typically require system calls
Shared memory communication only requires system calls to set up shared memory space
What are the pros of Message Passing?
Good for small amounts of data
Avoids issue of setting up the shared memory space