<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
		<id>https://gunkies.org/index.php?action=history&amp;feed=atom&amp;title=Xv6_homework_7</id>
		<title>Xv6 homework 7 - Revision history</title>
		<link rel="self" type="application/atom+xml" href="https://gunkies.org/index.php?action=history&amp;feed=atom&amp;title=Xv6_homework_7"/>
		<link rel="alternate" type="text/html" href="https://gunkies.org/w/index.php?title=Xv6_homework_7&amp;action=history"/>
		<updated>2026-05-12T00:34:48Z</updated>
		<subtitle>Revision history for this page on the wiki</subtitle>
		<generator>MediaWiki 1.30.1</generator>

	<entry>
		<id>https://gunkies.org/w/index.php?title=Xv6_homework_7&amp;diff=20427&amp;oldid=prev</id>
		<title>Jnc: +cat</title>
		<link rel="alternate" type="text/html" href="https://gunkies.org/w/index.php?title=Xv6_homework_7&amp;diff=20427&amp;oldid=prev"/>
				<updated>2018-12-30T13:57:45Z</updated>
		
		<summary type="html">&lt;p&gt;+cat&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr style=&quot;vertical-align: top;&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;Revision as of 13:57, 30 December 2018&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l1&quot; &gt;Line 1:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 1:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Since this has gone missing...&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Since this has gone missing...&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;pre&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;pre&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Lecture 7 homework&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Lecture 7 homework&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l36&quot; &gt;Line 36:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 37:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;(There is a very small but non-zero chance that the kernel will panic with the extra sti(); in kalloc. If the kernel does panic, make doubly sure that you removed the sti(); call from ide_rw. If it continues to panic and the only extra sti(); is in bio.c, then mail 6.828-staff@pdos.csail.mit.edu and think about buying a lottery ticket.)&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;(There is a very small but non-zero chance that the kernel will panic with the extra sti(); in kalloc. If the kernel does panic, make doubly sure that you removed the sti(); call from ide_rw. If it continues to panic and the only extra sti(); is in bio.c, then mail 6.828-staff@pdos.csail.mit.edu and think about buying a lottery ticket.)&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Turn in: Why does release clear lock-&amp;gt;pcs[0] and lock-&amp;gt;cpu before clearing lock-&amp;gt;locked? Why not wait until after?&amp;lt;/pre&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Turn in: Why does release clear lock-&amp;gt;pcs[0] and lock-&amp;gt;cpu before clearing lock-&amp;gt;locked? Why not wait until after?&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;/pre&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;#160;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;[[Category: Documentation]]&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;

&lt;!-- diff cache key mediawiki-wiki_:diff:version:1.11a:oldid:10690:newid:20427 --&gt;
&lt;/table&gt;</summary>
		<author><name>Jnc</name></author>	</entry>

	<entry>
		<id>https://gunkies.org/w/index.php?title=Xv6_homework_7&amp;diff=10690&amp;oldid=prev</id>
		<title>Neozeed: Created page with &quot;Since this has gone missing... &lt;pre&gt; Lecture 7 homework  Handed out: Wednesday, September 21, 2005 Due: Wednesday, September 28, Oct 3, 2005 Read: spinlock.c  Hand-In Procedure  ...&quot;</title>
		<link rel="alternate" type="text/html" href="https://gunkies.org/w/index.php?title=Xv6_homework_7&amp;diff=10690&amp;oldid=prev"/>
				<updated>2011-10-05T20:38:39Z</updated>
		
		<summary type="html">&lt;p&gt;Created page with &amp;quot;Since this has gone missing... &amp;lt;pre&amp;gt; Lecture 7 homework  Handed out: Wednesday, September 21, 2005 Due: Wednesday, September 28, Oct 3, 2005 Read: spinlock.c  Hand-In Procedure  ...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;Since this has gone missing...&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Lecture 7 homework&lt;br /&gt;
&lt;br /&gt;
Handed out: Wednesday, September 21, 2005&lt;br /&gt;
Due: Wednesday, September 28, Oct 3, 2005&lt;br /&gt;
Read: spinlock.c&lt;br /&gt;
&lt;br /&gt;
Hand-In Procedure&lt;br /&gt;
&lt;br /&gt;
You are to turn in this homework during lecture. Please write up your answers to the exercises below and hand them in to a 6.828 staff member by the end of the lecture.&lt;br /&gt;
&lt;br /&gt;
Assignment: In this assignment we will explore some of the interaction between interrupts and locking.&lt;br /&gt;
&lt;br /&gt;
Make sure you understand what would happen if the kernel executed the following code snippet:&lt;br /&gt;
&lt;br /&gt;
  struct spinlock lk;&lt;br /&gt;
  initlock(&amp;amp;lk, &amp;quot;test lock&amp;quot;);&lt;br /&gt;
  acquire(&amp;amp;lk);&lt;br /&gt;
  acquire(&amp;amp;lk);&lt;br /&gt;
(Feel free to use Bochs to find out.)&lt;br /&gt;
In xv6, the first acquire turns off interrupts on the local processor using cli, and interrupts remain off until the release of the last lock (at which point they are enabled using sti).&lt;br /&gt;
&lt;br /&gt;
Let's see what happens if we turn on interrupts while holding the ide lock. In ide_rw in ide.c, add a call to sti(); after the call to acquire. Rebuild the kernel and boot it in Bochs. The kernel should panic almost immediately.&lt;br /&gt;
&lt;br /&gt;
Turn in: explain in a few sentences why the kernel panicked. You may find it useful to look up the stack trace (the sequence of %eip values printed by panic) in the kernel.asm listing.&lt;br /&gt;
&lt;br /&gt;
Remove the sti(); you added, rebuild the kernel, and make sure it works again.&lt;br /&gt;
&lt;br /&gt;
Now let's see what happens if we turn on interrupts while holding the kalloc_lock. In kalloc in kalloc.c, add a call to sti(); after the call to acquire. You will also need to add #include &amp;quot;x86.h&amp;quot; at the top of the file after the other #include lines. Rebuild the kernel and boot it in Bochs. It will not panic.&lt;br /&gt;
&lt;br /&gt;
Turn in: explain in a few sentences why the kernel didn't panic. What is different about kalloc_lock as compared to ide_lock?&lt;br /&gt;
&lt;br /&gt;
You do not need to understand anything about the details of the IDE driver to answer this question, but you may find it helpful to look at which functions acquire each lock, and then at when those functions get called.&lt;br /&gt;
&lt;br /&gt;
(There is a very small but non-zero chance that the kernel will panic with the extra sti(); in kalloc. If the kernel does panic, make doubly sure that you removed the sti(); call from ide_rw. If it continues to panic and the only extra sti(); is in bio.c, then mail 6.828-staff@pdos.csail.mit.edu and think about buying a lottery ticket.)&lt;br /&gt;
&lt;br /&gt;
Turn in: Why does release clear lock-&amp;gt;pcs[0] and lock-&amp;gt;cpu before clearing lock-&amp;gt;locked? Why not wait until after?&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Neozeed</name></author>	</entry>

	</feed>