Operating Systems Flashcards
(127 cards)
What is kernel mode
TLDR: It gives unrestricted access to both user and OS memory, hardware, and system resources.
Explain variable partition scheme and what the hole is
It is when memory is separated into partitions, and each variably sized partition contains one process.
Initially, when all memory is available, this space is one large block called the hole
What is a problem suffered by first fit and best fit solution? Explain.
External fragmentation is a problem. This is when there is enough total memory space to satisfy a request, but the available spaces are not contiguous.
What is the 50 percent rule?
First fit analysis finds that given N blocks allocated in memory, another 50 percent of those blocks (0.5N) are lost to fragmentation.
What is compaction, under what conditions does it need to work?
Compaction is shuffling the holes in memory to place all free memory together.
This is only possible if relocation is dynamic and done at execution time by changing the base registers.
What is contiguous allocation?
OS is held in low memory with interrupt vectors. User processes are held in higher memory. (Memory is divided into 2 partitions).
It is when each process is stored in a single contiguous section of
memory
What is non contiguous allocation
Allows a process to acquire several memory blocks at different locations in memory. A process is split up into different partitions in memory. Reduces memory wastage from external and internal fragmentation.
Done through paging and segmentation.
Internal fragmentation (L17)
Allocated memory for a process may be larger than than requested memory, left with a small hole. This size difference between memory being used and the memory allocated, all within a partition.
In terms of paging, what is the worst case fragmentation? (L17)
Worst case fragmentation is when one frame only contains one byte.
Explain how segmentation works. (L17)
Programs are a collection of segments for things like main page, procedure, arrays, variables. The logical address consists of a tuple <segment number, offset>.
There is a segment table that has the segment number as index with a corresponding base address (which is the physical address where the segment starts in memory) and the limit (length of segment in main memory). The offset has to be less than the limit to be placed into main memory.
This has external fragmentation.
Explain the difference between segmentation and paging. (L17)
Long ass table, look it up in mindmap.
What is demand paging?
It’s like swapping and paging but processes are split into pages.
Demand paging is when you execute partially loaded processes. This is when processes are split into pages so that processes do not need to fully be in main memory for a part of a process to run, so each program takes less memory to run. Demand paging allows logical memory to exceed your physical memory, which allows for a higher degree of multiprogramming capabilities. How this is done is through using a secondary memory (swap space) (hard disk) to simulate the RAM by mapping some pages of a processes into it. Those pages are swapped into and out of main memory when a page fault occurs and is kept track of using a page table.
Essentially when a context switch occurs, the new process begins to execute after loading the first page and remaining pages are fetched (similar to paging system with swapping)
What is virtual memory?
Virtual memory is the technique that allows the execution of processes that are not completely in memory by storing part of s a program (pages) outside of main memory in a secondary storage space. Therefore, logical address space can exceed physical memory space and programs can take less memory to run.
This increases CPU utilisation and throughput, with no increase in response time or turnaround time, increasing degree of multiprogramming.
What is a page fault? How is it handled?
A page fault is when a page is marked invalid when you try to access it.
- Check internal table to see if reference was to a valid or invalid memory access.
- If invalid, terminate process. If page is just not in memory, then page it in.
- Find a free frame.
- Schedule the secondary storage operation to read the designated page into the newly allocated frame.
- When storage read is completed, modify the process’ page table to indicate it is in memory.
- Restart instruction and process accesses page. We save the state of interrupted process when page fault occurs.
What is degree of multiprogramming?
The degree of multiprogramming describes the maximum number of processes that a single-processor system can accommodate efficiently. It is the number of processes in ready state.
What does it mean when a bit is set to valid or invalid on a page table? What are two ways a bit can be invalid?
When a bit is set to valid in a page table, it means that page is available in the memory for the CPU to access (a memory resident). When a bit is set to invalid in the page table, it means that the page is either valid and in secondary storage or not loaded into the logical address space. Access to a page marked invalid causes a page fault, which traps to the OS.
What hardware is required to support demand paging?
- A page table is needed to mark validity
- Secondary memory is needed to swap pages into and out of main memory.
- The ability to restart instruction when a page fault occurs.
What is copy on write?
Copy on write is when a page of a process is copied when it is modified.
Parent and child processes can share pages in main memory. If either processes modify a shared page, only then is the page copied. This allows for more efficient process creation as only modified pages are copied.
Instead of immediately creating a copy of data when a process is duplicated, the system allows the copies to share the same memory space unless one of the copies are modified.
What is vfork()? Should it always be used?
vfork() is available on UNIX and is a variation of fork(). Instead of copy on write, parent process is suspended when a child process is using that address space of the parent’s. However, they must be careful to not modify address space. This should only be used when a child process calls exec() immediately.
What causes a need for page replacement?
When main memory is full and there are no free frames, but you need to bring in a page from secondary memory to continue a process, you need to find a page in memory that is not in use and page it out.
What is standard swapping and why is it no longer in use?
Entire processes can be temporarily swapped out of memory to a hacking store. Mostly idle processes are a good candidate. Makes it possible for total physical memory space of processed to exceed physical memory.
Most systems swap pages rather than entire processes now.
Explain the steps of basic page replacement.
- You find the location of a desired page in secondary store.
- If there are no free frames, use page replacement algorithm to select a victim frame. Write the victim frame to secondary store, update page/frame table accordingly.
- Read desired page into the newly freed frame, change page/frame table.
- Continue process by restarting the instruction that caused the trap (page fault)
How is overhead from basic page replacement reduced with a modify/dirty bit?
Each page or frame has a modify/dirty bit associated with it in the hardware. Bit is set by hardware whenever a page is modified so we know to write page to storage. If bit is not set, no need to write it to memory as it is already there (when a page is swapped into main memory, the page still exists in secondary storage).
What is the idea behind page fault algorithms?
We want the lowest page fault rates on both first access and re-access with algorithms. An algorithm is evaluated by running it on a string of memory references (reference string) and computing the number of page faults on that string.
If we have a reference to a page, then any references to page p that immediately follow will never cause a page fault.
Result of algorithm depends on number of frames available (higher # of frames, lower # of faults)