<?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_8</id>
		<title>Xv6 homework 8 - 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_8"/>
		<link rel="alternate" type="text/html" href="https://gunkies.org/w/index.php?title=Xv6_homework_8&amp;action=history"/>
		<updated>2026-05-10T09:53:02Z</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_8&amp;diff=20428&amp;oldid=prev</id>
		<title>Jnc: +cat</title>
		<link rel="alternate" type="text/html" href="https://gunkies.org/w/index.php?title=Xv6_homework_8&amp;diff=20428&amp;oldid=prev"/>
				<updated>2018-12-30T14:02:13Z</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 14:02, 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-l53&quot; &gt;Line 53:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 53:&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;#160;&amp;#160; setjmp in scheduler returned 0; longjmp&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;#160;&amp;#160; setjmp in scheduler returned 0; longjmp&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;but then some lines seem to be missing: this first longjmp does not behave like the others.&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;but then some lines seem to be missing: this first longjmp does not behave like the others.&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;Turn in: In the repeated six-line pattern, where does the longjmp in the scheduler return to (which line number in the printout)? Where does the very first longjmp in the scheduler return to (which line number in the printout)?&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;Turn in: In the repeated six-line pattern, where does the longjmp in the scheduler return to (which line number in the printout)? Where does the very first longjmp in the scheduler return to (which line number in the printout)?&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;&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;(Feel free to set a breakpoint at the return statement in longjmp to answer this question.)&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;(Feel free to set a breakpoint at the return statement in longjmp to answer this question.)&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;This completes the homework.&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;This completes the homework.&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;&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:10691:newid:20428 --&gt;
&lt;/table&gt;</summary>
		<author><name>Jnc</name></author>	</entry>

	<entry>
		<id>https://gunkies.org/w/index.php?title=Xv6_homework_8&amp;diff=10691&amp;oldid=prev</id>
		<title>Neozeed: Created page with &quot;Since this has gone missing...  &lt;pre&gt; Lecture 8 homework: Threads and Context Switching  Handed out: Wednesday, September 28, 2005 Due: Wednesday, October 5, 2005 Read: setjmp.S ...&quot;</title>
		<link rel="alternate" type="text/html" href="https://gunkies.org/w/index.php?title=Xv6_homework_8&amp;diff=10691&amp;oldid=prev"/>
				<updated>2011-10-05T20:39:10Z</updated>
		
		<summary type="html">&lt;p&gt;Created page with &amp;quot;Since this has gone missing...  &amp;lt;pre&amp;gt; Lecture 8 homework: Threads and Context Switching  Handed out: Wednesday, September 28, 2005 Due: Wednesday, October 5, 2005 Read: setjmp.S ...&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;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Lecture 8 homework: Threads and Context Switching&lt;br /&gt;
&lt;br /&gt;
Handed out: Wednesday, September 28, 2005&lt;br /&gt;
Due: Wednesday, October 5, 2005&lt;br /&gt;
Read: setjmp.S and proc.c (focus on the code that switches between processes, specifically scheduler and sched).&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;
Introduction&lt;br /&gt;
&lt;br /&gt;
In this homework you will investigate how the kernel switches between two processes.&lt;br /&gt;
&lt;br /&gt;
Assignment:&lt;br /&gt;
&lt;br /&gt;
In proc.c's scheduler there are two lines:&lt;br /&gt;
&lt;br /&gt;
      if(setjmp(&amp;amp;cpus[cpu()].jmpbuf) == 0)&lt;br /&gt;
        longjmp(&amp;amp;p-&amp;gt;jmpbuf);&lt;br /&gt;
Replace these with:&lt;br /&gt;
      cprintf(&amp;quot;setjmp called in scheduler\n&amp;quot;);&lt;br /&gt;
      if(setjmp(&amp;amp;cpus[cpu()].jmpbuf) == 0){&lt;br /&gt;
        cprintf(&amp;quot;setjmp in scheduler returned 0; longjmp\n&amp;quot;);&lt;br /&gt;
        longjmp(&amp;amp;p-&amp;gt;jmpbuf);&lt;br /&gt;
      }else&lt;br /&gt;
        cprintf(&amp;quot;setjmp in scheduler returned 1\n&amp;quot;);&lt;br /&gt;
Similarly, in sched, replace:&lt;br /&gt;
&lt;br /&gt;
  if(setjmp(&amp;amp;p-&amp;gt;jmpbuf) == 0)&lt;br /&gt;
    longjmp(&amp;amp;cpus[cpu()].jmpbuf);&lt;br /&gt;
with&lt;br /&gt;
  cprintf(&amp;quot;setjmp called in sched\n&amp;quot;);&lt;br /&gt;
  if(setjmp(&amp;amp;p-&amp;gt;jmpbuf) == 0){&lt;br /&gt;
    cprintf(&amp;quot;setjmp in sched returned 0; longjmp\n&amp;quot;);&lt;br /&gt;
    longjmp(&amp;amp;cpus[cpu()].jmpbuf);&lt;br /&gt;
  }else&lt;br /&gt;
    cprintf(&amp;quot;setjmp in sched returned 1\n&amp;quot;);&lt;br /&gt;
Rebuild your kernel and boot it on bochs. You will get around 150 printed lines about setjmp as the kernel boots.&lt;br /&gt;
&lt;br /&gt;
For now, ignore the first few lines of output. You should see a regular six-line pattern repeated over and over in the printed lines.&lt;br /&gt;
&lt;br /&gt;
Turn in: What is the six-line pattern? (The first line is setjmp called in scheduler.)&lt;br /&gt;
&lt;br /&gt;
Turn in: Why are there two setjmp returned prints for each setjmp called print?&lt;br /&gt;
&lt;br /&gt;
Now look at the first three lines of output about setjmp. You will notice that they do not follow the pattern. The first two lines are:&lt;br /&gt;
&lt;br /&gt;
  setjmp called in scheduler&lt;br /&gt;
  setjmp in scheduler returned 0; longjmp&lt;br /&gt;
but then some lines seem to be missing: this first longjmp does not behave like the others.&lt;br /&gt;
Turn in: In the repeated six-line pattern, where does the longjmp in the scheduler return to (which line number in the printout)? Where does the very first longjmp in the scheduler return to (which line number in the printout)?&lt;br /&gt;
&lt;br /&gt;
(Feel free to set a breakpoint at the return statement in longjmp to answer this question.)&lt;br /&gt;
&lt;br /&gt;
This completes the homework.&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Neozeed</name></author>	</entry>

	</feed>