Paging
A page of memory is the smallest fixed-length block of virtual memory managed by OS. To use virtual memory, the OS needs to transfer pages between the main memory and the secondary memory. Pages are stored in a page table. Each page has a virtual address called page number
Paging Life Cycle:
- If the page table finds a page in RAM (virtual address lookup), virtual memory mapping is established directly.
- When the virtual address lookup fails, a page fault is generated. Then page fault exception handler writes a victim page in cache to disk, and load the target page from disk. Meanwhile the page table updates the virtual address mapping
- In paging, writing from RAM to disk is faster in chunks than in individual bits.
Concurrency
Event Driven frameworks works by handling events one at a time:
select(fd_set *readfds, fd_set *writefds, fd_set *errorfds, struct timeval *timeout)
- takes in list of fds to check for reading, writing, or error condition pending.
- if no fd is ready for any of the above, it will poll, and block the thread until at least one fd is ready, within the timeout
- Each thread in Python occupies 8MB of virtual memory. However, only a small fraction of the virtual memory is mapped to the actual memory