Operating Systems Flashcards
(91 cards)
What is an operating system?
A software that acts as an interface between the user and hardware- mangaes resources and lets programs run
Why are operating systems important?
- Helps separate different parts of a system
- Allow devices to be used in flexible ways
- Make it possible for programs to run on different hardware types without changes
- Manages process
What is an API?
- Application Programming Interface
- Set of tools and functions that let programs talk to the OS
- Hides complex parts of how the system works (abstraction)
What are the types of memory allocation?
Static: Size is fixed before the program runs
Dynamic: Size can change while the program is running
What manages memory allocation?
Memory can be managed either by the application or by the OS itself
What does the Memory Management Unit do?
MMU helps manage memory by:
- Translates virtual to physical addresses
- Controlling access to memory
- Handling read/ write actions
- Storing permissions
- Dealing with memory errors
What is memory protection and why is it needed?
- Memory protection stops programs from changing memory they shouldn’t
- Checks access using virtual addresses and processor permissions to keep the system safe
What are the types of memory permissions?
- No access: Not allowed to access
- Read-only: Can read but not change
- Supervisor read/ write: Only the system can change it
- Read/ write: Full access to read and change
What is the purpose of memory management in processes?
To ensure processes remain independant and have controlled access to resources
What does each process have to prevent interference?
Its own address space for reading and writing
What type of addresses do processes use and how are they handled?
They use virtual addresses which system maps to physical memory
How are addresses translated in memory mapping?
- Organised into software pages
- MSB of address defines the page number
- Only the page number is translated
- Some pages can be invalid (not mapped to RAM)
What are base and limit registers used for?
Base: Start of physical address
Limit: Size of the memory range
What happens when physical memory is full?
Swapping/ paging moves some pages to disk to free space
Why is RAM important for reducing swapping?
Because swapping is slow, more RAM reduces the need for it
What are the memory allocation strategies for a new process?
First fit: Fast but can cause fragmentation
Best fit: Efficient but more complex
Worst fit: Uses the largest gap, may leave leftover space
What is external and internal fragmentation?
External: Enough free memory exists but not in one contiguous block- requires reorganisation
Internal: Unused memory in partitions; memory is seperated in blocks, not individual locations
Why is virtual memory used?
Virtual memory allows more processes to run without frequent swapping. Efficient mapping is needed.
What are the 2 locality principles?
Spacial locality: Nearby addresses likely used soon
Temporal locality: Recently used addressed likely used again
How do caches work and why is flushing important?
- Caches store frequently accesssed data near the CPU to improve speed
- Intercept known requests and store unknown ones for future use
- Flushing to avoid context switches, where a virtual address may change its meaning
How is a virtual address structured?
Virtual address = Page number (MSB) + Offset (location in page)
How are virtual addresses translated?
- Page tables map virtual pages to physical ones
- 2^32 locations with 4KiB (2^12) pages- 2^20 entries
- TLB caches recent translations
How are pages mapped efficiently?
- Sparse data structures are used to fill only necessary table entries
- Hierarchal paging follows pointers between branches
What is a page fault and how is it handled?
- If page is not in memory MMU triggers a page fault + causes OS call
- Page must be swapped from disk, but time consuming so can be offloaded to DMA
- Page tables must be updated accordingly