Please enable JavaScript.
Coggle requires JavaScript to display documents.
COMP3231 - Coggle Diagram
COMP3231
Processes and Threads
-
-
-
-
-
-
States
-
Blocked
We also have a series of blocked queues for each kind of event, so we know what process to release
Ready
Goes into the ready queue, and is picked up by the scheduler.
Virtual Memory
-
Overview
-
Each process is assigned multiple pages, with a virtual address space per process
-
-
Virutal memory is contiguous for process, but physical memory isn't.
-
-
Page Table
-
2 Level Page tale
10 bit first level table, referencing tables
10 bit second level table, referencing PTEs
Inverted Page Table
-
Algo: compute hash of page number, extract index, get frame.
IPTs grow with RAM, not address space.
-
Hashed Page Table
Hash to VPN to index, and entry has both VPN and PFN, also a next for collisions.
-
-
-
Management Policies
Page size: large pages means
:check: Less pages
:check: Better TLB coverage
:check: Increased I/O throughput
:red_cross: Increased internal frag
:red_cross: Increased page fault latency
-
-
-
Cleaning Policy
-
Precleaning: pages are written out in batches. (in background, pagedaemon)
File Management
-
-
-
-
Directories
-
-
-
-
Hierarchical, with a current working directory for relative file access.
-
I/O Management
Device Drivers
-
-
-
Can either return immediately, or block and wait from a response from the hardware.
Thread safe, so they can be called by another process.
-
-
-
-
Management Software
-
I/O Layers
-
- Device Independet OS Software
-
-
-
Interrupt Handlers
Can execute at any time, causing concurrency issues.
Steps
-
-
- Ack/Mask interrupt controller
- Run interrupt service process
- Load new/original process registers
-
-
-
-
File System Internals
-
-
-
Allocation methods
Contiguous: one block after the other.
:check: faster at reading
:check: easy bookkeeping
:red_cross: need max file size
:red_cross: causes ext frag
Dynamic: random choice of blocks
:check: no ext frag.
:check: no pre-allocating
:red_cross: internal frag
:red_cross: scattered blocks
:red_cross: complex metadata
-
File Allocation Table: keep the linked list part in memory. A bit faster. Finding free blocks is slow
inode: blocks stored per file. Only keep open files in memory. Fast Random access. Allocated dynamically.
Free block management
Linked list on disk, in free blocks.
- can be reordered in background.
- only one block of pointers in main memory
Bit maps
- Too big for main memory.
- good for ext frag tho.
Consistency
-
Metadata is prioritised as losing that corrupts (immediate write). Losing data is just a loss of changes (periodic write).
-
Multiprocessor
-
-
-
OS Structure
OS for each CPU: issues:
- each processor has its own scheduling queue.
- each processor has its own memory partition
-
Spinlocks
Normal Test and Set, but hardware blocks all other accesses to it during the instruction.
Causes bus contention
-
Spin on read of value. When the value is invalidated, race to main memory to perform TSL
-
Scheduling
-
-
Non-preemptive: processes mush yield control, and let others control it.
Scheduling Algorithms
-
Interactive Systems
Goals:
- minimise response time
- Provide proportionality (short jobs short, long jobs long)
-
Priorities
Like round robin, but with productivity levels.
-
UNIX Scheduler: priority = cpu usage + nice (given by user) + base (hardcoded in)
High is bad, low is good.
Realtime Systems
Goals:
- meet deadlines
- provide predictability
-
Buffering
-
User Level Buffering
-
Only a single syscall, and block/wakeup per data buffer
Single Buffer
-
-
Speed up: (T+C)/(max(T,C) + M)
-
-
-
Double Buffer
-
Device writes to one buffer, User reads from the other.
Speed up: (T+C)/max(T, C+M)
-
Deadlock
-
Conditions
-
-
-
Circular Wait condition: Must be a circular chain of 2 or more.
Can be modelled with directed graphs. Resources are squares, processes are circles.
Solutions
- Ostrich Algorithm: Pretend there isn't a problem. Restart when there is. Widely used due to rarity.
- Prevention: Prevent one of the four conditions.
Hold and Wait: Release if deadlock is caused and try again. Could cause livelock: constantly hitting deadlock, make no progress.
Circular Wait: Compute and detect deadlock and programatically prevent it. Commonly used for more critical systems.
-
-
Safe: not deadlocked now, and there is a scheduling order that won't cause deadlock.
Bankers Algorithm: every time someone wants a resource, we check the state. If it will push us into an unsafe, we make them wait until its safe.
-
-
Memory Management
-
-
Swapping
A process can be swapped out of memory into hard drive storage, then back into memory to continue execution.
-
I/O Interaction
-
-
Direct Memory Access
Transfers data between memory and device, no need for CPU
-
-
System Calls
Special function calls that:
- Provide entry into kernel
- Perform privileged op
- Return to caller
-