<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://homeostasis.scs.carleton.ca/wiki/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Jamesklau</id>
	<title>Soma-notes - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://homeostasis.scs.carleton.ca/wiki/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Jamesklau"/>
	<link rel="alternate" type="text/html" href="https://homeostasis.scs.carleton.ca/wiki/index.php/Special:Contributions/Jamesklau"/>
	<updated>2026-05-12T20:52:32Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.42.1</generator>
	<entry>
		<id>https://homeostasis.scs.carleton.ca/wiki/index.php?title=Operating_Systems_2017F_Lecture_6&amp;diff=21072</id>
		<title>Operating Systems 2017F Lecture 6</title>
		<link rel="alternate" type="text/html" href="https://homeostasis.scs.carleton.ca/wiki/index.php?title=Operating_Systems_2017F_Lecture_6&amp;diff=21072"/>
		<updated>2017-10-04T04:53:56Z</updated>

		<summary type="html">&lt;p&gt;Jamesklau: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Video==&lt;br /&gt;
&lt;br /&gt;
Video from the lecture given on September 26, 2017 [http://homeostasis.scs.carleton.ca/~soma/os-2017f/lectures/comp3000-2017f-lec06-26Sep2017.mp4 is now available].&lt;br /&gt;
&lt;br /&gt;
==Code==&lt;br /&gt;
&lt;br /&gt;
Code and files from the lecture (captured as they were at the end) are available [http://homeostasis.scs.carleton.ca/~soma/os-2017f/code/lec06/ here].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Notes==&lt;br /&gt;
====What is a tar file?====&lt;br /&gt;
* A tar file stands for tape archive&lt;br /&gt;
&lt;br /&gt;
====Building a Kernel====&lt;br /&gt;
*Check the current version &lt;br /&gt;
**Cd linux-source-4.4.0&lt;br /&gt;
&lt;br /&gt;
*To become root&lt;br /&gt;
**Sudo su -&lt;br /&gt;
&lt;br /&gt;
*To configure a linux kernel:&lt;br /&gt;
**Make menuconfig : to set options with an interface &lt;br /&gt;
**Make localmodcomfig : to create a configuration based on modules loaded&lt;br /&gt;
**Make oldconfig : to use a previously generated .config (cd/boot)&lt;br /&gt;
**Ls mod: list all the mod that are loaded (only built)&lt;br /&gt;
&lt;br /&gt;
*To build a configured kernel from source:&lt;br /&gt;
**Make: build the main kernel&lt;br /&gt;
**Make modules: build the modules&lt;br /&gt;
&lt;br /&gt;
*To install a built kernel:&lt;br /&gt;
** Sudo make install: put the kernel in /boot&lt;br /&gt;
**Sudo make modules_install: puts the module in appropriate directory&lt;br /&gt;
**Update-grub: tell the boot loader(grub) about the mew kernel and makes it bootable&lt;br /&gt;
&lt;br /&gt;
*Reboot to run the new kernel:&lt;br /&gt;
**Sync&lt;br /&gt;
**Sudo shutdown -r now&lt;br /&gt;
&lt;br /&gt;
*Check the version: Cat /proc/version&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Dynamic linking====&lt;br /&gt;
*Brk: allocates space from the kernel&lt;br /&gt;
*It is smaller in disk but bigger in memory&lt;br /&gt;
*It shared library&lt;/div&gt;</summary>
		<author><name>Jamesklau</name></author>
	</entry>
	<entry>
		<id>https://homeostasis.scs.carleton.ca/wiki/index.php?title=Operating_Systems_2017F_Lecture_5&amp;diff=21071</id>
		<title>Operating Systems 2017F Lecture 5</title>
		<link rel="alternate" type="text/html" href="https://homeostasis.scs.carleton.ca/wiki/index.php?title=Operating_Systems_2017F_Lecture_5&amp;diff=21071"/>
		<updated>2017-10-04T04:46:25Z</updated>

		<summary type="html">&lt;p&gt;Jamesklau: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Video==&lt;br /&gt;
&lt;br /&gt;
Video from the lecture given on September 21, 2017 [http://homeostasis.scs.carleton.ca/~soma/os-2017f/lectures/comp3000-2017f-lec05-21Sep2017.mp4 is now available].&lt;br /&gt;
&lt;br /&gt;
==Code==&lt;br /&gt;
&lt;br /&gt;
Code and files from the lecture (captured as they were at the end) are available [http://homeostasis.scs.carleton.ca/~soma/os-2017f/code/lec05/ here].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Notes==&lt;br /&gt;
&lt;br /&gt;
====IO Redirection====&lt;br /&gt;
*The &amp;gt; operator output to a location&lt;br /&gt;
**Eg. Ls &amp;gt; foo.txt&lt;br /&gt;
&lt;br /&gt;
*The | operator connect the output of the 1st program to the input of the 2nd program&lt;br /&gt;
**Eg. Shuf foo.txt | shuf &amp;gt; shuf2.txt (pipe operater connect output of shuf foo.txt to input of shuf then output to shuf2.txt)&lt;br /&gt;
&lt;br /&gt;
*File usually comes with standard input (0), standard output(1),standard error(error message, port 2). This defined when program started&lt;br /&gt;
**Ls foo &amp;gt; test.txt 2 &amp;gt;error.txt: redirect error message (port 2) of foo to error.txt&lt;br /&gt;
*Ls foo&amp;gt;&amp;amp; all.txt: redirect everything to output file&lt;br /&gt;
**Bc -l: This command bring up the calculater&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Manipulating environment variables====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
int main(int argc, char *argv[], char *envp[]){&lt;br /&gt;
While (envp[i] != NULL) {&lt;br /&gt;
     If (strcmp(“User=“, envp[i], 5){&lt;br /&gt;
         printf(“%s\n”, envp[i]);&lt;br /&gt;
	 char *username = envp[i] +5;  //pointer arithmetic &lt;br /&gt;
     }&lt;br /&gt;
     I++;&lt;br /&gt;
}&lt;br /&gt;
printf (“%s\n”, username);&lt;br /&gt;
return 0;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*Getopt: a better way to find environmental variable&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Signals====&lt;br /&gt;
*Kill: send a signal to destroy a program&lt;br /&gt;
**Kill -stop 5617(This stop a progam)  and   Kill -cont 5617(resume a program)&lt;br /&gt;
**Sigkill, sigterm (ctrl+c),  sigstop (ctrl+z), sigpipe (when | died), sighup (when close terminal window)&lt;br /&gt;
**Sigchild(when a child process terminated),&lt;/div&gt;</summary>
		<author><name>Jamesklau</name></author>
	</entry>
	<entry>
		<id>https://homeostasis.scs.carleton.ca/wiki/index.php?title=Operating_Systems_2017F_Lecture_3&amp;diff=21070</id>
		<title>Operating Systems 2017F Lecture 3</title>
		<link rel="alternate" type="text/html" href="https://homeostasis.scs.carleton.ca/wiki/index.php?title=Operating_Systems_2017F_Lecture_3&amp;diff=21070"/>
		<updated>2017-10-04T04:27:47Z</updated>

		<summary type="html">&lt;p&gt;Jamesklau: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Video==&lt;br /&gt;
&lt;br /&gt;
Video from the lecture given on September 14, 2017 [http://homeostasis.scs.carleton.ca/~soma/os-2017f/lectures/comp3000-2017f-lec03-14Sep2017.mp4 is now available].&lt;br /&gt;
&lt;br /&gt;
==Code==&lt;br /&gt;
&lt;br /&gt;
Code and files from the lecture (captured as they were at the end) are available [http://homeostasis.scs.carleton.ca/~soma/os-2017f/code/lec03/ here].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Notes==&lt;br /&gt;
====Commands ====&lt;br /&gt;
*-wall: show all warning&lt;br /&gt;
*less: allow screen navigation, hit q to quit&lt;br /&gt;
&lt;br /&gt;
==== What is fork? ====&lt;br /&gt;
* Fork creates a new program but contains the same code (call the clone system call) and only argv[] and envp[] passed on to the new born program&lt;br /&gt;
&lt;br /&gt;
==== What Happen to the child process after the parent process died? ====&lt;br /&gt;
*Every child process must have a currently running parent. When the parent process die, kernel collect the dead body(return value) and re-parent the process &lt;br /&gt;
* In the demo showed in class, “system d user” became its new parent&lt;br /&gt;
**Use command &amp;quot;Pstree&amp;quot; to show process hierarchy&lt;br /&gt;
&lt;br /&gt;
==== What is zombie process? ====&lt;br /&gt;
*When a process die it become &#039;zombie&#039; (s = sleep, z = zombie)&lt;br /&gt;
*We can use wait to be a &#039;good&#039; parent&lt;br /&gt;
&lt;br /&gt;
==== How to load a new binary manually====&lt;br /&gt;
*Use the execve command.&lt;br /&gt;
**We can fork child process to handle dangerous task (“Suicide Squad”), or handle all incoming request&lt;br /&gt;
&lt;br /&gt;
==== Manipulating environment variables====&lt;br /&gt;
*argc tells the number of argument in command line, while argv[] contains the actual command obtained in the command line&lt;/div&gt;</summary>
		<author><name>Jamesklau</name></author>
	</entry>
</feed>