<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Project 2: Processes and Time-Sharing the CPU on CS 1670: Operating Systems</title><link>https://csci1670.github.io/docs/project2/</link><description>Recent content in Project 2: Processes and Time-Sharing the CPU on CS 1670: Operating Systems</description><generator>Hugo</generator><language>en-us</language><atom:link href="https://csci1670.github.io/docs/project2/index.xml" rel="self" type="application/rss+xml"/><item><title>Appendix A: ARM64 additions</title><link>https://csci1670.github.io/docs/project2/arm64/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://csci1670.github.io/docs/project2/arm64/</guid><description>&lt;style&gt;
 section {
 margin-bottom: 2rem;
 padding: 0em 1em;
 padding-bottom: 1em;
 border-radius: 4px;

 background-color: #f7f7f7;
 border: 1px solid #ccc;
 }
 center {
 text-align: center;
 }
 summary {
 font-weight: bolder;
 }
 summary:hover {
 text-decoration: underline
 }
&lt;/style&gt;
&lt;h1 id="appendix-a-arm64-additions-for-project-2"&gt;
 Appendix A: ARM64 additions for Project 2
 &lt;a class="anchor" aria-hidden="true" href="#appendix-a-arm64-additions-for-project-2"&gt;&lt;/a&gt;
&lt;/h1&gt;
&lt;p&gt;This appendix covers what is new relative to &lt;a href="https://csci1670.github.io/docs/project1/arm64"&gt;Project 1&amp;rsquo;s ARM64 reference&lt;/a&gt;, which you should still keep at hand.&lt;/p&gt;
&lt;h3 id="instructions"&gt;
 Instructions
 &lt;a class="anchor" aria-hidden="true" href="#instructions"&gt;&lt;/a&gt;
&lt;/h3&gt;
&lt;table&gt;
	&lt;thead&gt;
			&lt;tr&gt;
					&lt;th&gt;Instruction&lt;/th&gt;
					&lt;th&gt;Meaning&lt;/th&gt;
			&lt;/tr&gt;
	&lt;/thead&gt;
	&lt;tbody&gt;
			&lt;tr&gt;
					&lt;td&gt;&lt;code&gt;stp x0, x1, [sp, #16]&lt;/code&gt;&lt;/td&gt;
					&lt;td&gt;&lt;strong&gt;St&lt;/strong&gt;ore &lt;strong&gt;p&lt;/strong&gt;air: store two registers at &lt;code&gt;sp+16&lt;/code&gt; and &lt;code&gt;sp+24&lt;/code&gt;. Halves the instruction count when saving a context.&lt;/td&gt;
			&lt;/tr&gt;
			&lt;tr&gt;
					&lt;td&gt;&lt;code&gt;ldp x0, x1, [x2, #16]&lt;/code&gt;&lt;/td&gt;
					&lt;td&gt;&lt;strong&gt;L&lt;/strong&gt;oa&lt;strong&gt;d p&lt;/strong&gt;air: the inverse, loads a pair of registers.&lt;/td&gt;
			&lt;/tr&gt;
			&lt;tr&gt;
					&lt;td&gt;&lt;code&gt;eret&lt;/code&gt;&lt;/td&gt;
					&lt;td&gt;&lt;strong&gt;E&lt;/strong&gt;xception &lt;strong&gt;ret&lt;/strong&gt;urn. Sets &lt;code&gt;pc&lt;/code&gt; from &lt;code&gt;ELR_ELn&lt;/code&gt; and &lt;code&gt;PSTATE&lt;/code&gt; from &lt;code&gt;SPSR_ELn&lt;/code&gt; (for the current exception level &lt;em&gt;n&lt;/em&gt;) in one step. Used both to drop an exception level and to resume a saved context.&lt;/td&gt;
			&lt;/tr&gt;
			&lt;tr&gt;
					&lt;td&gt;&lt;code&gt;msr DAIFSET, #2&lt;/code&gt;&lt;/td&gt;
					&lt;td&gt;&lt;strong&gt;Mask&lt;/strong&gt; (disable) interrupts. The immediate is a 4-bit selector over the &lt;code&gt;PSTATE&lt;/code&gt; mask bits: 8 = Debug, 4 = SError, 2 = IRQ, 1 = FIQ. So &lt;code&gt;#2&lt;/code&gt; touches only the IRQ mask.&lt;/td&gt;
			&lt;/tr&gt;
			&lt;tr&gt;
					&lt;td&gt;&lt;code&gt;msr DAIFCLR, #2&lt;/code&gt;&lt;/td&gt;
					&lt;td&gt;&lt;strong&gt;Unmask&lt;/strong&gt; (enable) interrupts; same selector encoding.&lt;/td&gt;
			&lt;/tr&gt;
			&lt;tr&gt;
					&lt;td&gt;&lt;code&gt;wfi&lt;/code&gt; / &lt;code&gt;wfe&lt;/code&gt;&lt;/td&gt;
					&lt;td&gt;&lt;strong&gt;W&lt;/strong&gt;ait &lt;strong&gt;f&lt;/strong&gt;or &lt;strong&gt;i&lt;/strong&gt;nterrupt / &lt;strong&gt;e&lt;/strong&gt;vent: put the core in a low-power state until something happens. A good way to park a CPU core that has nothing to do.&lt;/td&gt;
			&lt;/tr&gt;
			&lt;tr&gt;
					&lt;td&gt;&lt;code&gt;svc #0&lt;/code&gt;&lt;/td&gt;
					&lt;td&gt;&lt;strong&gt;S&lt;/strong&gt;uper&lt;strong&gt;v&lt;/strong&gt;isor &lt;strong&gt;c&lt;/strong&gt;all: deliberately raise a synchronous exception. This is how system calls will work in Project 4; here it is useful for testing your exception vector table.&lt;/td&gt;
			&lt;/tr&gt;
			&lt;tr&gt;
					&lt;td&gt;&lt;code&gt;.balign N&lt;/code&gt;&lt;/td&gt;
					&lt;td&gt;(An assembler directive, not an instruction.) Advance to the next address that is a multiple of &lt;code&gt;N&lt;/code&gt;, padding as needed. Essential for laying out an exception vector table.&lt;/td&gt;
			&lt;/tr&gt;
	&lt;/tbody&gt;
&lt;/table&gt;
&lt;h3 id="system-registers"&gt;
 System registers
 &lt;a class="anchor" aria-hidden="true" href="#system-registers"&gt;&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;Remember that all of these are read with &lt;code&gt;mrs&lt;/code&gt; and written with &lt;code&gt;msr&lt;/code&gt;, never &lt;code&gt;mov&lt;/code&gt;, and that most of them exist separately at each exception level.&lt;/p&gt;</description></item><item><title>Appendix B: Hardware Manuals</title><link>https://csci1670.github.io/docs/project2/manuals/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://csci1670.github.io/docs/project2/manuals/</guid><description>&lt;style&gt;
 section {
 margin-bottom: 2rem;
 padding: 0em 1em;
 padding-bottom: 1em;
 border-radius: 4px;

 background-color: #f7f7f7;
 border: 1px solid #ccc;
 }
 center {
 text-align: center;
 }
 summary {
 font-weight: bolder;
 }
 summary:hover {
 text-decoration: underline
 }
&lt;/style&gt;
&lt;h1 id="appendix-b-hardware-manuals-for-project-2"&gt;
 Appendix B: Hardware manuals for Project 2
 &lt;a class="anchor" aria-hidden="true" href="#appendix-b-hardware-manuals-for-project-2"&gt;&lt;/a&gt;
&lt;/h1&gt;
&lt;p&gt;Project 1 needed one manual; this project needs three, because the pieces of hardware you are programming belong to different vendors.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;1. The &lt;a href="https://support.arm.com/documentation/ddi0487/mc/?lang=en"&gt;&lt;em&gt;Arm Architecture Reference Manual for A-profile&lt;/em&gt; (ARMv8-A)&lt;/a&gt;.&lt;/strong&gt; This is the authority on everything in &lt;a href="https://csci1670.github.io/docs/project2/arm64/"&gt;Appendix A&lt;/a&gt;: exception levels, the exception model, the vector table layout, &lt;code&gt;PSTATE&lt;/code&gt;, and the generic timer. It is several thousand pages long and you should not read it linearly. The chapters you may be interested in are the ones on the AArch64 exception model (what the CPU does on an exception; the vector table) and on the generic timer (the &lt;code&gt;CNT*&lt;/code&gt; registers). The register descriptions are in the &amp;ldquo;AArch64 System Register Descriptions&amp;rdquo; part, alphabetically. While you can use it, we instead recommend &lt;a href="https://arm.jonpalmisc.com/"&gt;Jon Palmisciano&amp;rsquo;s ARM reference&lt;/a&gt;, which contains the same information but makes it searchable and presents it more compactly.&lt;/p&gt;</description></item><item><title>Appendix C: Debugging Concurrency</title><link>https://csci1670.github.io/docs/project2/debug/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://csci1670.github.io/docs/project2/debug/</guid><description>&lt;style&gt;
 section {
 margin-bottom: 2rem;
 padding: 0em 1em;
 padding-bottom: 1em;
 border-radius: 4px;

 background-color: #f7f7f7;
 border: 1px solid #ccc;
 }
 center {
 text-align: center;
 }
 summary {
 font-weight: bolder;
 }
 summary:hover {
 text-decoration: underline
 }
&lt;/style&gt;
&lt;h1 id="appendix-c-debugging-concurrency"&gt;
 Appendix C: Debugging concurrency
 &lt;a class="anchor" aria-hidden="true" href="#appendix-c-debugging-concurrency"&gt;&lt;/a&gt;
&lt;/h1&gt;
&lt;p&gt;Everything in &lt;a href="https://csci1670.github.io/docs/project1/debug/"&gt;Project 1&amp;rsquo;s testing and debugging appendix&lt;/a&gt; still applies. What follows is the additional toolkit for this project, where bugs are no longer purely about &lt;em&gt;what&lt;/em&gt; your code does but also about &lt;em&gt;when&lt;/em&gt;.&lt;/p&gt;</description></item><item><title>Appendix D: Assertions and Debug Output</title><link>https://csci1670.github.io/docs/project2/assertions/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://csci1670.github.io/docs/project2/assertions/</guid><description>&lt;style&gt;
 section {
 margin-bottom: 2rem;
 padding: 0em 1em;
 padding-bottom: 1em;
 border-radius: 4px;

 background-color: #f7f7f7;
 border: 1px solid #ccc;
 }
 center {
 text-align: center;
 }
 summary {
 font-weight: bolder;
 }
 summary:hover {
 text-decoration: underline
 }
&lt;/style&gt;
&lt;h1 id="appendix-d-assertions-and-debug-output"&gt;
 Appendix D: Assertions and debug output
 &lt;a class="anchor" aria-hidden="true" href="#appendix-d-assertions-and-debug-output"&gt;&lt;/a&gt;
&lt;/h1&gt;
&lt;p&gt;Kernel bugs are unusually hard to find, and this project makes your kernel much more complex, which invites new classes of bugs. Because your OS doesn&amp;rsquo;t have memory protection yet, a bug can quietly corrupt memory and the machine misbehaves thousands of instructions later in code that is entirely innocent. And there is concurrency, so the misbehaviour may not even show up in the same &lt;em&gt;process&lt;/em&gt; as the bug.&lt;/p&gt;</description></item></channel></rss>