<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://homeostasis.scs.carleton.ca/wiki/index.php?action=history&amp;feed=atom&amp;title=Operating_Systems_2020W_Final_Exam_Review</id>
	<title>Operating Systems 2020W Final Exam Review - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://homeostasis.scs.carleton.ca/wiki/index.php?action=history&amp;feed=atom&amp;title=Operating_Systems_2020W_Final_Exam_Review"/>
	<link rel="alternate" type="text/html" href="https://homeostasis.scs.carleton.ca/wiki/index.php?title=Operating_Systems_2020W_Final_Exam_Review&amp;action=history"/>
	<updated>2026-05-13T00:39:11Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.42.1</generator>
	<entry>
		<id>https://homeostasis.scs.carleton.ca/wiki/index.php?title=Operating_Systems_2020W_Final_Exam_Review&amp;diff=22630&amp;oldid=prev</id>
		<title>Soma: Created page with &quot;==Video==  Video from the exam review on April 9, 2020 [https://homeostasis.scs.carleton.ca/~soma/os-2020w/lectures/comp3000-2020w-examreview-20200409.m4v is now available]....&quot;</title>
		<link rel="alternate" type="text/html" href="https://homeostasis.scs.carleton.ca/wiki/index.php?title=Operating_Systems_2020W_Final_Exam_Review&amp;diff=22630&amp;oldid=prev"/>
		<updated>2020-04-09T21:19:47Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;==Video==  Video from the exam review on April 9, 2020 [https://homeostasis.scs.carleton.ca/~soma/os-2020w/lectures/comp3000-2020w-examreview-20200409.m4v is now available]....&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;==Video==&lt;br /&gt;
&lt;br /&gt;
Video from the exam review on April 9, 2020 [https://homeostasis.scs.carleton.ca/~soma/os-2020w/lectures/comp3000-2020w-examreview-20200409.m4v is now available].&lt;br /&gt;
&lt;br /&gt;
==Notes==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Final Exam Review&lt;br /&gt;
-----------------&lt;br /&gt;
&lt;br /&gt;
A3 topics&lt;br /&gt;
 - equivalence between named pipes and (unnamed) pipes from pipe()&lt;br /&gt;
 - general understanding of pipes&lt;br /&gt;
    - what you can and can&amp;#039;t do with them&lt;br /&gt;
    - specifically, you can&amp;#039;t seek on pipes (go backwards, forwards)&lt;br /&gt;
    - can only read or write (depending on which side of the pipe you have)&lt;br /&gt;
    - so can only substitute for regular files in these limited contexts&lt;br /&gt;
      (no seeking, only reading or only writing linearly)&lt;br /&gt;
 - understanding conditional variables and semaphores&lt;br /&gt;
    - why they require special implementations&lt;br /&gt;
    - the basic logic of them&lt;br /&gt;
    - how poor implementations can lead to deadlock&lt;br /&gt;
 - processes versus threads&lt;br /&gt;
    - how to create a process vs how to create a thread&lt;br /&gt;
    - how making a thread shares memory while a process copies memory&lt;br /&gt;
      - note how we had to create special shared memory with two&lt;br /&gt;
        processes but didn&amp;#039;t have to with threads, because all is shared&lt;br /&gt;
 - character devices, block devices&lt;br /&gt;
    - how to create from scratch&lt;br /&gt;
    - significance of major/minor numbers&lt;br /&gt;
 - difference between uid and euid&lt;br /&gt;
    - how uid is used to indicate process ownership, while&lt;br /&gt;
      euid indicates process privileges&lt;br /&gt;
    - if you own a process, you can send signals to it (i.e., you can&lt;br /&gt;
      kill it)&lt;br /&gt;
 - basic understanding of what the kernel tracks (in the task_struct)&lt;br /&gt;
   versus what users see, what is in kernel space and what isn&amp;#039;t&lt;br /&gt;
    - specifically, uid/gid vs usernames and groups&lt;br /&gt;
 &lt;br /&gt;
A4/T8 topics&lt;br /&gt;
 - difference between virtual and physical memory&lt;br /&gt;
   - file mmap&amp;#039;d into two processes: could have same virtual addresses&lt;br /&gt;
     but do not have to.  Will have same physical addresses&lt;br /&gt;
     (because same file, loaded only once and shared)&lt;br /&gt;
   - processes can control layout of virtual memory&lt;br /&gt;
     - if you coded everything, could control where mmap puts things (mostly),&lt;br /&gt;
       ask for areas of virtual address space to be made valid or invalid,&lt;br /&gt;
       change binary so code and data are loaded in different places&lt;br /&gt;
   - processes can&amp;#039;t directly control physical memory&lt;br /&gt;
     - kernel does what it wants with it&lt;br /&gt;
 - kernel vfs&lt;br /&gt;
   - how modules can define file operations for devices by specifying function&lt;br /&gt;
     pointers in a struct&lt;br /&gt;
      - can choose functions for read, write, lseek, ioctl, etc&lt;br /&gt;
      - if you don&amp;#039;t define, userspace gets error when trying&lt;br /&gt;
        to do that system call on your character device&lt;br /&gt;
 - ioctl&lt;br /&gt;
   - how it only applies to devices, not regular files&lt;br /&gt;
   - how tty&amp;#039;s are character devices, and how ioctl&amp;#039;s allow&lt;br /&gt;
     us to control tty&amp;#039;s&lt;br /&gt;
 - page sizes in the Linux kernel&lt;br /&gt;
   - how they are architecture dependent, but the kernel source&lt;br /&gt;
     abstracts them so most of the kernel doesn&amp;#039;t care&lt;br /&gt;
   - page sizes are determined by the CPU&lt;br /&gt;
 - page offsets versus page numbers&lt;br /&gt;
    - how lower bits of virtual address encodes an offset in a page&lt;br /&gt;
 - walking a page table&lt;br /&gt;
    - how you do lookups at each level which give the physical address&lt;br /&gt;
      of the page containing the next level, until we get to the data page&lt;br /&gt;
    - physical address is really a &amp;quot;page number&amp;quot;, i.e. pointer with lower&lt;br /&gt;
      PAGE_SIZE bits set to 0&lt;br /&gt;
&lt;br /&gt;
A4/T9 topics&lt;br /&gt;
 - you can use -D on command line to define things in a C program, like #define&lt;br /&gt;
    - how this can be used to change how programs are compiled&lt;br /&gt;
 - how with eBPF (as implemented in bcc) the python code runs in userspace, but&lt;br /&gt;
   compiles and loads C programs into kernel space (the actual eBPF code)&lt;br /&gt;
 - eBPF programs can watch every system call and arbitrary numbers of&lt;br /&gt;
   kernel functions and functions in processes (specified by PID or by&lt;br /&gt;
   library or executable) - crazy powerful&lt;br /&gt;
 - how eBPF can do much more than ptrace-based programs (strace, gdb)&lt;br /&gt;
    - ptrace only allows for monitoring one process at a time&lt;br /&gt;
    - eBPF can watch everything in kernel and userspace&lt;br /&gt;
 - how eBPF can do powerful things so has to be restricted to root&lt;br /&gt;
    - what kind of things can it do that regular processes can&amp;#039;t do,&lt;br /&gt;
      even ones running as root?&lt;br /&gt;
 - how ridiclously often filter() was called in 3000shellwatch.py/bpfprogram.c&lt;br /&gt;
 - probes can run on function/system call start or exit&lt;br /&gt;
 - signals (like users) are represented as numbers, not strings, in&lt;br /&gt;
   the kernel (although signals are encoded using #define&amp;#039;s in the&lt;br /&gt;
   kernel source)&lt;br /&gt;
 - permissions&lt;br /&gt;
    - symbolic versus octal&lt;br /&gt;
       rwxrwxrwx vs 0777&lt;br /&gt;
    - only care about read, write, execute permissions&lt;br /&gt;
      (other things are encoded in these bits like setuid, not on exam)&lt;br /&gt;
 - safety of eBPF versus regular kernel modules&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Midterm topics&lt;br /&gt;
 - see the midterm review&lt;br /&gt;
 - see the midterm questions&lt;br /&gt;
&lt;br /&gt;
------------------------------------------&lt;br /&gt;
BELOW IS EXTRA MATERIAL&lt;br /&gt;
&lt;br /&gt;
Topics to discuss&lt;br /&gt;
 - mmap&lt;br /&gt;
 - page table lookups&lt;br /&gt;
&lt;br /&gt;
eBPF safety&lt;br /&gt;
 - clear termination (can calculate when loops terminate)&lt;br /&gt;
 - safe memory access (no dangerous pointer arithmetic)&lt;br /&gt;
 - ?&lt;br /&gt;
&lt;br /&gt;
Page tables are simple data structures&lt;br /&gt;
 - have to be, are traversed by hardware, and need to be done quickly&lt;br /&gt;
&lt;br /&gt;
What it is doing is splitting up the bits of a virtual address into&lt;br /&gt;
offsets into lookup pages&lt;br /&gt;
 - each lookup page is an array of &amp;quot;pointers&amp;quot;,&lt;br /&gt;
   really page numbers (i.e., lower PAGE_SIZE bits are ignored)&lt;br /&gt;
 - in a 4K page, we can fit 2^9 64 bit pointers&lt;br /&gt;
 - we need 9 bits to specify each location in a page&lt;br /&gt;
 - so page table lookups are literally&lt;br /&gt;
   - use pointer P to find page of physical memory M&lt;br /&gt;
&lt;br /&gt;
64 bit virtual addresses, 57 bit physical addresses with 5-level page tables&lt;br /&gt;
&lt;br /&gt;
 9-bits  9-bits   9-bits  9-bits  9-bits  12-bits  = 57 bits&lt;br /&gt;
 pgd     p4d      pud     pmd     pte&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
start with pointer to page table (which is a pointer to a page)&lt;br /&gt;
  - this is the pgd page&lt;br /&gt;
  - in that page, use pgd bits in the virtual addess to get a 9-bit number&lt;br /&gt;
  - that 9 bit number (0-511) is an offset into the page&lt;br /&gt;
  - (the page is a 512 element array, with each element&lt;br /&gt;
     consisting of an 8-byte pointer)&lt;br /&gt;
  - use this pointer to get the p4d page&lt;br /&gt;
  &lt;br /&gt;
Do the same thing for the p4d page, pud page, pmd page, and pte page&lt;br /&gt;
 - 5 levels&lt;br /&gt;
&lt;br /&gt;
when you do the lookup in the PTE page, you get a pointer to the data page&lt;br /&gt;
 - where the actual process data is&lt;br /&gt;
 - last 12 bits of virtual address is an offset into this page&lt;br /&gt;
&lt;br /&gt;
All these calculations ARE NOT ON THE FINAL&lt;br /&gt;
 - just the idea of 5-level page tables&lt;br /&gt;
 - difference between virtual and physical addresses&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Soma</name></author>
	</entry>
</feed>