<?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_2026F_Lecture_6</id>
	<title>Operating Systems 2026F Lecture 6 - 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_2026F_Lecture_6"/>
	<link rel="alternate" type="text/html" href="https://homeostasis.scs.carleton.ca/wiki/index.php?title=Operating_Systems_2026F_Lecture_6&amp;action=history"/>
	<updated>2026-10-05T10:57:18Z</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_2026F_Lecture_6&amp;diff=25181&amp;oldid=prev</id>
		<title>Soma: Created page with &quot;==Video==  Video from the lecture given on October 2, 2026 is now available: * [https://homeostasis.scs.carleton.ca/~soma/os-2026f/lectures/comp3000-2026f-lec06-20261002.mp4 Lecture 6]  ==Notes==  ===Lecture 6===  &lt;pre&gt; Lecture 6 ---------  Signals  What is a signal?  - message from the kernel to a process  - can originate from the kernel or from another process  Idea: interrupt the process to handle an event  - so a simple form of event handling, or more exception handl...&quot;</title>
		<link rel="alternate" type="text/html" href="https://homeostasis.scs.carleton.ca/wiki/index.php?title=Operating_Systems_2026F_Lecture_6&amp;diff=25181&amp;oldid=prev"/>
		<updated>2026-10-02T14:02:07Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;==Video==  Video from the lecture given on October 2, 2026 is now available: * [https://homeostasis.scs.carleton.ca/~soma/os-2026f/lectures/comp3000-2026f-lec06-20261002.mp4 Lecture 6]  ==Notes==  ===Lecture 6===  &amp;lt;pre&amp;gt; Lecture 6 ---------  Signals  What is a signal?  - message from the kernel to a process  - can originate from the kernel or from another process  Idea: interrupt the process to handle an event  - so a simple form of event handling, or more exception handl...&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 October 2, 2026 is now available:&lt;br /&gt;
* [https://homeostasis.scs.carleton.ca/~soma/os-2026f/lectures/comp3000-2026f-lec06-20261002.mp4 Lecture 6]&lt;br /&gt;
&lt;br /&gt;
==Notes==&lt;br /&gt;
&lt;br /&gt;
===Lecture 6===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Lecture 6&lt;br /&gt;
---------&lt;br /&gt;
&lt;br /&gt;
Signals&lt;br /&gt;
&lt;br /&gt;
What is a signal?&lt;br /&gt;
 - message from the kernel to a process&lt;br /&gt;
 - can originate from the kernel or from another process&lt;br /&gt;
&lt;br /&gt;
Idea: interrupt the process to handle an event&lt;br /&gt;
 - so a simple form of event handling, or more exception handling&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
When a process receives a signal&lt;br /&gt;
 - it stops executing the current code (function)&lt;br /&gt;
 - it instead starts running the appropriate signal handler&lt;br /&gt;
 - when handling is complete, it then returns to where it was, continuing the function&lt;br /&gt;
&lt;br /&gt;
This means signals can interrupt almost ANY part of your program&lt;br /&gt;
 - need to be prepared!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
What sort of signals are there?&lt;br /&gt;
 - user defined (SIGUSR1, SIGUSR2)&lt;br /&gt;
 - memory access errors (SIGSEGV, SIGBUS)&lt;br /&gt;
 - some floating point errors&lt;br /&gt;
&lt;br /&gt;
But mainly:&lt;br /&gt;
 - when child processes terminate (SIGCHLD)&lt;br /&gt;
 - when the user wants to terminate the process (SIGTERM)&lt;br /&gt;
   or suspend (SIGSTOP)&lt;br /&gt;
&lt;br /&gt;
And many other conditions&lt;br /&gt;
&lt;br /&gt;
Signal handlers are defined by default by the C library&lt;br /&gt;
&lt;br /&gt;
you can change signals with sigaction()&lt;br /&gt;
 (don&amp;#039;t use signal)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
So what bad things can happen to your program because of a signal handler?&lt;br /&gt;
 - could interrupt critical code&lt;br /&gt;
   - can even happen while doing a system call&lt;br /&gt;
 - handler could mess up state of your code&lt;br /&gt;
&lt;br /&gt;
When a process receives a signal while in a system call, we have two choices:&lt;br /&gt;
 - continue the system call after the signal is handled&lt;br /&gt;
    - that doesn&amp;#039;t work because of how the kernel operates&lt;br /&gt;
    - but we can do the system call from the beginning (restart it)&lt;br /&gt;
 - cancel the system call after the signal is handled&lt;br /&gt;
&lt;br /&gt;
Standard I/O file descriptors&lt;br /&gt;
 - when you type &amp;quot;ls&amp;quot;, its output goes to the terminal&lt;br /&gt;
 - but all ls was doing was writing to standard out&lt;br /&gt;
 - how did standard out end up in the terminal?&lt;br /&gt;
&lt;br /&gt;
C standard in    = file descriptor 0 in Linux/UNIX&lt;br /&gt;
C standard out   = file descriptor 1 in Linux/UNIX&lt;br /&gt;
C standard error = file descriptor 2 in Linux/UNIX&lt;br /&gt;
&lt;br /&gt;
What is a file descriptor?&lt;br /&gt;
 - small number&lt;br /&gt;
 - refers to an open file&lt;br /&gt;
&lt;br /&gt;
A file descriptor is what UNIX uses instead of the FILE struct for C.&lt;br /&gt;
&lt;br /&gt;
But what is that small number, really?&lt;br /&gt;
 - index into an array of open files the kernel maintains&lt;br /&gt;
   for the currently running process&lt;br /&gt;
&lt;br /&gt;
When a program starts, 0, 1, and 2 file descriptors are expected to be open and ready to go, with 0 ready for reads and 1 and 2 ready for writes.&lt;br /&gt;
&lt;br /&gt;
Who gets these file descriptors set up? Whomever did the execve!&lt;br /&gt;
 - they could inherit them from who execve&amp;#039;d them, but they are responsible&lt;br /&gt;
&lt;br /&gt;
When you&amp;#039;re using a shell, the shell is responsible for setting up the standard I/O file descriptors.&lt;br /&gt;
&lt;br /&gt;
This is good, because it lets us do I/O redirection&lt;br /&gt;
&lt;br /&gt;
So what does &amp;quot;&amp;gt;&amp;quot; do in most shells?&lt;br /&gt;
 - redirects standard output to the given file&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Remember that &amp;quot;files&amp;quot; in UNIX can be stored on disk, but they can be many other things as well&lt;br /&gt;
 - tty&amp;#039;s/pseudo tty&amp;#039;s&lt;br /&gt;
 - another process (IPC, inter-process communication)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Soma</name></author>
	</entry>
</feed>