mirror of
https://github.com/CoderSherlock/CoderSherlock.github.io.git
synced 2026-06-13 08:08:10 -07:00
Update xv6
This commit is contained in:
+40
-4
@@ -6,10 +6,46 @@
|
||||
</description>
|
||||
<link>https://codersherlock.github.com//</link>
|
||||
<atom:link href="https://codersherlock.github.com//feed.xml" rel="self" type="application/rss+xml"/>
|
||||
<pubDate>Wed, 26 Jul 2017 12:52:19 -0400</pubDate>
|
||||
<lastBuildDate>Wed, 26 Jul 2017 12:52:19 -0400</lastBuildDate>
|
||||
<pubDate>Fri, 28 Jul 2017 15:25:24 -0400</pubDate>
|
||||
<lastBuildDate>Fri, 28 Jul 2017 15:25:24 -0400</lastBuildDate>
|
||||
<generator>Jekyll v3.5.1</generator>
|
||||
|
||||
<item>
|
||||
<title>Xv6 introduction</title>
|
||||
<description><p>I hate xv6, a stupid, useless education-oriented system. In this article, I will generally talk about how to implement system call to this operating system.</p>
|
||||
|
||||
<hr />
|
||||
|
||||
<h2 id="xv6-systemcall">Xv6 Systemcall</h2>
|
||||
<p>To invoke a system call, we have to first define a user mode function to be the interface of the kernel instruction in file <em>user.h</em>.</p>
|
||||
|
||||
<div class="language-c highlighter-rouge"><pre class="highlight"><code><span class="kt">void</span> <span class="n">function</span> <span class="p">(</span><span class="kt">void</span><span class="p">);</span>
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<p>This interface-like function will then pass the function name, in this case function, to <em>usys.S</em>. When using user mode function in programs, <em>usys.S</em> will generate a reference to SYS_function and push system call number of this function into %eax. After that, system can know from <em>syscall.c</em> and determining whether this system call is available. We must define same name system function and add it into <em>syscall.h</em> and <em>syscall.c</em>.</p>
|
||||
|
||||
<div class="language-c highlighter-rouge"><pre class="highlight"><code><span class="cp">#define SYS_function ## // ## is the system call number
|
||||
</span>
|
||||
<span class="p">[</span><span class="n">SYS_function</span><span class="p">]</span> <span class="n">sys_function</span> <span class="c1">// real system function name
|
||||
</span>
|
||||
<span class="k">extern</span> <span class="kt">int</span> <span class="n">sys_function</span><span class="p">(</span><span class="kt">void</span><span class="p">);</span> <span class="c1">// real system function declaration
|
||||
</span></code></pre>
|
||||
</div>
|
||||
|
||||
<p>After adding these sentences to syscall files, we can implement real function in specific place where you want to make the function works well.</p>
|
||||
|
||||
<p>Sometimes, we need to pass variables among system calls. In this case, variables’ values are not necessary and even can’t be pass directly into system_function. When invoke a system call function, all variables of this system call will be pushed into current process’ stack. In file <em>syscall.c</em>, multiple functions are provided to get these variables from the process. I won’t waste time on explaining how to use these functions especially when elegant and detailed comments were written in source codes. However, I will explain concepts and how process organized and works in xv6 in future articles.</p>
|
||||
</description>
|
||||
<pubDate>Fri, 28 Jul 2017 14:56:55 -0400</pubDate>
|
||||
<link>https://codersherlock.github.com//archivers/intro-xv6</link>
|
||||
<guid isPermaLink="true">https://codersherlock.github.com//archivers/intro-xv6</guid>
|
||||
|
||||
|
||||
<category>xv6</category>
|
||||
|
||||
</item>
|
||||
|
||||
<item>
|
||||
<title>Short talk about Unikernels</title>
|
||||
<description><h2 id="what-is-unikernel">What is Unikernel?</h2>
|
||||
@@ -32,8 +68,8 @@
|
||||
|
||||
</description>
|
||||
<pubDate>Wed, 26 Jul 2017 12:42:33 -0400</pubDate>
|
||||
<link>https://codersherlock.github.com//archivers/term-comp</link>
|
||||
<guid isPermaLink="true">https://codersherlock.github.com//archivers/term-comp</guid>
|
||||
<link>https://codersherlock.github.com//archivers/intro-unikernel</link>
|
||||
<guid isPermaLink="true">https://codersherlock.github.com//archivers/intro-unikernel</guid>
|
||||
|
||||
|
||||
<category>unikernel</category>
|
||||
|
||||
Reference in New Issue
Block a user