<?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_2021F_Lecture_22</id>
	<title>Operating Systems 2021F Lecture 22 - 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_2021F_Lecture_22"/>
	<link rel="alternate" type="text/html" href="https://homeostasis.scs.carleton.ca/wiki/index.php?title=Operating_Systems_2021F_Lecture_22&amp;action=history"/>
	<updated>2026-04-06T04:46:33Z</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_2021F_Lecture_22&amp;diff=23577&amp;oldid=prev</id>
		<title>Soma: Created page with &quot;==Video==  Video from the lecture given on December 7, 2021 is now available: * [https://homeostasis.scs.carleton.ca/~soma/os-2021f/lectures/comp3000-2021f-lec22-20211207.m4v...&quot;</title>
		<link rel="alternate" type="text/html" href="https://homeostasis.scs.carleton.ca/wiki/index.php?title=Operating_Systems_2021F_Lecture_22&amp;diff=23577&amp;oldid=prev"/>
		<updated>2021-12-07T19:10:26Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;==Video==  Video from the lecture given on December 7, 2021 is now available: * [https://homeostasis.scs.carleton.ca/~soma/os-2021f/lectures/comp3000-2021f-lec22-20211207.m4v...&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 December 7, 2021 is now available:&lt;br /&gt;
* [https://homeostasis.scs.carleton.ca/~soma/os-2021f/lectures/comp3000-2021f-lec22-20211207.m4v video]&lt;br /&gt;
* [https://homeostasis.scs.carleton.ca/~soma/os-2021f/lectures/comp3000-2021f-lec22-20211207.cc.vtt auto-generated captions]&lt;br /&gt;
Video is also available through Brightspace (Resources-&amp;gt;Class zoom meetings-&amp;gt;Cloud Recordings tab)&lt;br /&gt;
&lt;br /&gt;
==Notes==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Lecture 22&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
When you make a system call, what is happening?&lt;br /&gt;
 - process executes &amp;quot;syscall&amp;quot; instruction&lt;br /&gt;
 - causes CPU to go into supervisor mode&lt;br /&gt;
 - jumps to system call entry point into kernel&lt;br /&gt;
 - syscall entry looks at CPU registers, decides&lt;br /&gt;
   what system call was requested&lt;br /&gt;
     - note this is all in assembly generally&lt;br /&gt;
 - calls appropriate system call, it does its thing&lt;br /&gt;
     - this is in C, but with weird declarations&lt;br /&gt;
       (SYSCALL_DEFINE0, SYSCALL_DEFINE1, etc)&lt;br /&gt;
     - in the kernel, the process that made the system call&lt;br /&gt;
       is represented by current (type struct task_struct)&lt;br /&gt;
 - when system call code returns, kernel&lt;br /&gt;
   switches back to user mode via the scheduler&lt;br /&gt;
     - decides what process to run next&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
CPU registers&lt;br /&gt;
 - think of them as hard-coded variables&lt;br /&gt;
    - limited number of them&lt;br /&gt;
    - the storage you can actually do computation on&lt;br /&gt;
    - basic flow (load/store architecture)&lt;br /&gt;
      - load values into registers from memory&lt;br /&gt;
      - do operations on registers, with results in&lt;br /&gt;
        registers&lt;br /&gt;
      - save registers to memory&lt;br /&gt;
 - when you make a system call registers hold&lt;br /&gt;
   system call parameters&lt;br /&gt;
     - this can also happen when you call a C function,&lt;br /&gt;
       but it depends on the compiler&lt;br /&gt;
     - system call ABI (application binary interface)&lt;br /&gt;
       is explicitly defined by the Linux kernel&lt;br /&gt;
&lt;br /&gt;
Remember with the file API there is always file state&lt;br /&gt;
for open files&lt;br /&gt;
 - our position in the file&lt;br /&gt;
&lt;br /&gt;
The implicit in userspace must be explicit in kernelspace&lt;br /&gt;
 - we have to represent our position in the file&lt;br /&gt;
&lt;br /&gt;
mutex&lt;br /&gt;
 - ensure exclusive access to a resource&lt;br /&gt;
 - essentially, a lock&lt;br /&gt;
 - needed when concurrent access to something&lt;br /&gt;
   could mess it up (i.e., messing up a data structure&lt;br /&gt;
   or variable)&lt;br /&gt;
 - (a mutex is a semaphore that can have a value of 0 or 1)&lt;br /&gt;
 - (for mutual exclusion, hence the name)&lt;br /&gt;
 &lt;br /&gt;
condition variable&lt;br /&gt;
 - wait on an event to happen&lt;br /&gt;
   - so one party waits while another tells it&lt;br /&gt;
     to stop waiting&lt;br /&gt;
&lt;br /&gt;
In this situation, the condition variable is the resource&lt;br /&gt;
being protected by the mutex&lt;br /&gt;
&lt;br /&gt;
A virtual address can be divided into a virtual page number&lt;br /&gt;
 and an offset within a page&lt;br /&gt;
  - so to go to physical memory, we map the page number&lt;br /&gt;
    to a frame&lt;br /&gt;
  - we just copy the offset - it isn&amp;#039;t changed&lt;br /&gt;
    (it is just an index into a 4k array, which is the page)&lt;br /&gt;
&lt;br /&gt;
slab allocation in the kernel&lt;br /&gt;
 - used for kernel data structures&lt;br /&gt;
 - on top of virtual memory&lt;br /&gt;
&lt;br /&gt;
slab allocation is just a fancy malloc&lt;br /&gt;
 - that understands patterns in the kinds of data being allocated&lt;br /&gt;
&lt;br /&gt;
The idea is that we don&amp;#039;t want to waste time allocating&lt;br /&gt;
data structures&lt;br /&gt;
 - so reuse them when we can&lt;br /&gt;
 - initialize in the background, not on critical paths&lt;br /&gt;
&lt;br /&gt;
remember dynamic memory allocation is expensive&lt;br /&gt;
 - often a huge bottleneck in any complex program&lt;br /&gt;
&lt;br /&gt;
To solve this, use custom memory allocators&lt;br /&gt;
 - the slab allocator is just the kernel&amp;#039;s&lt;br /&gt;
&lt;br /&gt;
garbage collection is a fancy memory management strategy&lt;br /&gt;
used for languages with heavy uses of dynamic memory allocation&lt;br /&gt;
 - basically, used when you don&amp;#039;t explicitly free&lt;br /&gt;
   allocated storage&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Why do we use pages?&lt;br /&gt;
 - because allocating/deallocating fixed-sized chunks&lt;br /&gt;
   of memory is about as efficient as we can get&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Soma</name></author>
	</entry>
</feed>