1. The composition of an operating system (OS) - Process - A running program - Instructions, data, stack (procedure calls) - Thread - The segment of a process - Each thread has its own variable and states - Share memory space with other threads - Take less time in the creation - Kernel space - Privilege instructions - User space - User program, process - System call - back and forth the kernel space and the user space, e.g. trap - Trap - User program issues a signal - Used to execute a specific functionality in the OS - Use return-from-trap instruction to leave kernel space - Interrupt - A hardware or software signal - Notify the CPU a critical process needs urgent execution - interrupt vector (INT 80) - Exception - Synchronous events generated by the process - When should we use exception? illegal instructions, divide-by-0 - Address space - The abstraction of physical memory - Code (top)-> instructions, code segment - Why do we put code at the top of the address space? - Stack (bottom)-> Keep track of where it is in the function call chain - Heap (top)-> dynamically-allocated, user-managed memory e.g. malloc() - Could we change the order of the stack and heap ? - Virtual memory - Hide the memory access in the physical memory - Goals of the virtual memory - transparency - efficiency - How to efficiently and flexibly virtualize memory? - protection - protect processes from one another (isolation) - Memory address translation - base and bound - memory management unit (MMU) as the part of the processor - Paging - solving memory space-management problem - segmentation -> chop things up into variable-sized pieces - different-size chunks -> fragmented - paging -> chop up space into fixed-sized pieces (page) - page table - per-process data stucture - store address translations for each of the virtual pages of the address space - Where are page tables stored? - the paging is slow, why? - Lock - ensure the correctness of the concurrency - File system