<?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_Lecture_20</id>
	<title>Operating Systems 2020W Lecture 20 - 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_Lecture_20"/>
	<link rel="alternate" type="text/html" href="https://homeostasis.scs.carleton.ca/wiki/index.php?title=Operating_Systems_2020W_Lecture_20&amp;action=history"/>
	<updated>2026-06-02T22:26:50Z</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_Lecture_20&amp;diff=22621&amp;oldid=prev</id>
		<title>Soma: Created page with &quot;==Video==  Video from the lecture given on March 25, 2020 [https://homeostasis.scs.carleton.ca/~soma/os-2020w/lectures/comp3000-2020w-lec20-20200325.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_Lecture_20&amp;diff=22621&amp;oldid=prev"/>
		<updated>2020-03-25T20:09:00Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;==Video==  Video from the lecture given on March 25, 2020 [https://homeostasis.scs.carleton.ca/~soma/os-2020w/lectures/comp3000-2020w-lec20-20200325.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 lecture given on March 25, 2020 [https://homeostasis.scs.carleton.ca/~soma/os-2020w/lectures/comp3000-2020w-lec20-20200325.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;
Lecture 20&lt;br /&gt;
----------&lt;br /&gt;
 - Assignment 3 solutions&lt;br /&gt;
 - scheduling&lt;br /&gt;
&lt;br /&gt;
If you are a few minutes late in submitting your assignment it is okay, but please upload your solutions now&lt;br /&gt;
&lt;br /&gt;
Assignment 4 is due April 3rd&lt;br /&gt;
 - but you&amp;#039;re answering multiple choice questions, posted by Monday&lt;br /&gt;
 - General questions are up now, you should try answering those&lt;br /&gt;
   (solutions for them will be posted but we won&amp;#039;t grade answers,&lt;br /&gt;
    will just do auto-grading of multiple choice questions)&lt;br /&gt;
&lt;br /&gt;
Final exam will be similar to the midterm, but covering the whole class&lt;br /&gt;
 - difficulty will be similar as if you look back at the midterm,&lt;br /&gt;
   open book would only have helped for a few questions&lt;br /&gt;
&lt;br /&gt;
You&amp;#039;ll submit a text file via cuLearn&lt;br /&gt;
 - I&amp;#039;ll give you all a template for the text file along with the questions&lt;br /&gt;
 - Please fill out the template so we can use scripts to assist with grading&lt;br /&gt;
&lt;br /&gt;
Final exam grade replaces midterm if you do better on the final&lt;br /&gt;
&lt;br /&gt;
(And I will make adjustments to compensate for A3 difficulty, so&lt;br /&gt;
 focus on learning the material!)&lt;br /&gt;
&lt;br /&gt;
Review session for final&lt;br /&gt;
 - last class will be solutions for A4 plus exam review&lt;br /&gt;
&lt;br /&gt;
Participation marks cannot lower your grade&lt;br /&gt;
 - will also calculate grades with 20% assignments, 20% tutorials, 0%&lt;br /&gt;
   participation&lt;br /&gt;
&lt;br /&gt;
So hopefully most of you will get a 4% boost from participation&lt;br /&gt;
&lt;br /&gt;
Interviews will start by April 20th.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Assignment 3 solutions&lt;br /&gt;
 - Q1: pipes (named &amp;amp; created by pipe())&lt;br /&gt;
 - Q2: understanding the logic behind semaphores and condition variables&lt;br /&gt;
       (separate from their implementation)&lt;br /&gt;
       Why two cores?&lt;br /&gt;
         - without 2 cores, only one process/thread can execute at a time&lt;br /&gt;
	 - means that the only concurrency you have is one being interrupted&lt;br /&gt;
	   at arbitrary times.  (In practice it tends not to be so arbitrary)&lt;br /&gt;
	 - e.g., you&amp;#039;ll see deadlock much less often with only one core&lt;br /&gt;
 - Q3: see how to make threads, compare with making processes with fork&lt;br /&gt;
    - multiple ways to get a working implementation&lt;br /&gt;
    - TAs will do their best to grade fairly, don&amp;#039;t need to do exactly&lt;br /&gt;
      what was in the solutions&lt;br /&gt;
        - probably better to just add parameters to the shared struct!&lt;br /&gt;
        - main thing is you used threads and not processes,&lt;br /&gt;
	  and got rid of the mmap and the shared memory hints to pthread&lt;br /&gt;
	  (calls to setpshared)&lt;br /&gt;
 - Q4: understand the steps in creating a device in the kernel&lt;br /&gt;
       see that the device files created are nothing special,&lt;br /&gt;
       could have been created manually&lt;br /&gt;
       (note that device files in /dev/pts are an exception, because&lt;br /&gt;
        they are actually device files in a special filesystem,&lt;br /&gt;
	so have weird semantics.  Devices in /dev are &amp;quot;normal&amp;quot;)&lt;br /&gt;
       you can copy device files between filesystems most of the time,&lt;br /&gt;
       for &amp;quot;normal&amp;quot; device files&lt;br /&gt;
&lt;br /&gt;
 - Q5: understand how character device modules work&lt;br /&gt;
       - how read/write access is determined&lt;br /&gt;
       - how the fops struct controls what functions are&lt;br /&gt;
         called for file operations&lt;br /&gt;
       understand the significance of uid vs euid (vs. pid)&lt;br /&gt;
        - be able to express in english&lt;br /&gt;
       get experience navigating the kernel source code&lt;br /&gt;
        - see how to call kernel code by following examples in&lt;br /&gt;
	  the code base&lt;br /&gt;
       understand better the task abstraction for processes &amp;amp; threads&lt;br /&gt;
       kernel space vs user space (and transferring data safely between them)&lt;br /&gt;
&lt;br /&gt;
    using helper function in the kernel is the best way to access things&lt;br /&gt;
      - I got a bit sloppy in part when I directly accessed task-&amp;gt;cred-&amp;gt;uid&lt;br /&gt;
      &lt;br /&gt;
    How do debug kernel modules?&lt;br /&gt;
      - printk is most straightforward&lt;br /&gt;
      - there are ways to use gdb (kgdb) but the setup is non-trivial&lt;br /&gt;
      - there&amp;#039;s a reason why it is good to code in userspace!&lt;br /&gt;
      - and why eBPF is so wonderful!&lt;br /&gt;
    Why used current_ns?  because seems dangerous to use any other namespace (to me)&lt;br /&gt;
       - but I could be convinced&lt;br /&gt;
 Q6: realize that some things (like usernames) are purely in userspace,&lt;br /&gt;
     kernel knows nothing about them&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(Optional info)&lt;br /&gt;
Traditionally on Linux systems, logs are in /var/log&lt;br /&gt;
 - /var is for data that is variable (get it?)&lt;br /&gt;
 - logs can be put there by individual applications, normally in&lt;br /&gt;
   their own subdirectory&lt;br /&gt;
 - traditionally syslogd would handle the other log files, but&lt;br /&gt;
   now that is part of systemd&lt;br /&gt;
 - in fact, with systemd these text logs are copies of data in a binary&lt;br /&gt;
   log (stored in /var/log/journal), can read this log directly&lt;br /&gt;
   with journalctl&lt;br /&gt;
 - kernel logs go to the console initially, then go to a userspace program&lt;br /&gt;
   that has requested access to the kernel logging buffer&lt;br /&gt;
     - traditionally klogd, now part of systemd&lt;br /&gt;
     - copies of kernel logs are put in /var/log/kern.log, can&lt;br /&gt;
       get current ones with dmesg&lt;br /&gt;
 - log rotation is responsible for files with a number after them&lt;br /&gt;
   - periodically current logs are moved to a numbered log file&lt;br /&gt;
   - older logs are compressed, and oldest are deleted&lt;br /&gt;
   - keeps logs from taking up all of the disk (generally)&lt;br /&gt;
 - journalctl has lots of ways to select which logs are shown&lt;br /&gt;
   - or you use grep on the text logs&lt;br /&gt;
&lt;br /&gt;
systemd is a project to replace much of the core userspace functionality on&lt;br /&gt;
linux systems.  Controversial but now ubiquitous.  Replaces lots of low level&lt;br /&gt;
stuff including&lt;br /&gt;
 - init&lt;br /&gt;
 - networking&lt;br /&gt;
 - logging&lt;br /&gt;
 - kernel module loading&lt;br /&gt;
 - container management (partial)&lt;br /&gt;
 - getty (login from a console)&lt;br /&gt;
 - time management&lt;br /&gt;
 - others&lt;br /&gt;
Complaint is systemd replaced stuff that wasn&amp;#039;t broken.  Response is a&lt;br /&gt;
unified approach to this functionality provides lots of benefits&lt;br /&gt;
(power management, fast boot in particular)&lt;br /&gt;
&lt;br /&gt;
See https://www.freedesktop.org/wiki/Software/systemd/&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Process states&lt;br /&gt;
 - # cores = # processes (maximum) in the running state&lt;br /&gt;
 - everyone else is waiting for some reason&lt;br /&gt;
   - waiting for I/O (e.g. waiting for the disk)&lt;br /&gt;
   - sleeping (nothing to do)&lt;br /&gt;
   - idle (waiting to be scheduled, to get access to a core)&lt;br /&gt;
&lt;br /&gt;
grep State /proc/*/status | grep -v idle | grep -v sleeping | less&lt;br /&gt;
 - to see what is not sleeping or idle&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Soma</name></author>
	</entry>
</feed>