addsystemcall.rar

  • PUDN用户
    了解作者
  • Unix_Linux
    开发工具
  • 137KB
    文件大小
  • rar
    文件格式
  • 0
    收藏次数
  • 1 积分
    下载积分
  • 23
    下载次数
  • 2009-10-21 11:19
    上传日期
怎样像UNIX/MINIX系统中添加自己的System Call以用来调用
addsystemcall.rar
  • How_to_add_system_call.pdf
    143.1KB
内容介绍
<html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta charset="utf-8"> <meta name="generator" content="pdf2htmlEX"> <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> <link rel="stylesheet" href="https://static.pudn.com/base/css/base.min.css"> <link rel="stylesheet" href="https://static.pudn.com/base/css/fancy.min.css"> <link rel="stylesheet" href="https://static.pudn.com/prod/directory_preview_static/6247140854457c44d029f582/raw.css"> <script src="https://static.pudn.com/base/js/compatibility.min.js"></script> <script src="https://static.pudn.com/base/js/pdf2htmlEX.min.js"></script> <script> try{ pdf2htmlEX.defaultViewer = new pdf2htmlEX.Viewer({}); }catch(e){} </script> <title></title> </head> <body> <div id="sidebar" style="display: none"> <div id="outline"> </div> </div> <div id="pf1" class="pf w0 h0" data-page-no="1"><div class="pc pc1 w0 h0"><img class="bi x0 y0 w1 h1" alt="" src="https://static.pudn.com/prod/directory_preview_static/6247140854457c44d029f582/bg1.jpg"><div class="c x1 y1 w2 h2"><div class="t m0 x2 h3 y2 ff1 fs0 fc0 sc0 ls0 ws0">Karthick Jayar<span class="_ _0"></span>aman (Syracuse University)<span class="ff2"> <span class="_ _1"> </span></span>SEE<span class="_ _2"></span>D Documen<span class="_ _0"></span>t <span class="fc1 sc0"> </span><span class="fc1 sc0"> </span><span class="fc1 sc0"> </span><span class="fc1 sc0"> </span><span class="fc1 sc0"> </span><span class="fc1 sc0"> </span><span class="fc1 sc0"> </span><span class="fc1 sc0"> </span><span class="fc1 sc0"> </span><span class="fc1 sc0"> </span><span class="fc1 sc0"> </span><span class="fc1 sc0"> </span><span class="fc1 sc0"> </span><span class="fc1 sc0"> </span><span class="fc1 sc0"> </span><span class="fc1 sc0"> </span><span class="fc1 sc0"> </span><span class="fc1 sc0"> </span><span class="fc1 sc0"> </span><span class="fc1 sc0"> </span><span class="fc1 sc0"> </span><span class="fc1 sc0"> </span><span class="fc1 sc0"> </span><span class="fc1 sc0"> </span><span class="fc1 sc0"> </span><span class="fc1 sc0"> </span><span class="fc1 sc0"> </span><span class="fc1 sc0"> </span><span class="fc1 sc0"> </span><span class="fc1 sc0"> </span><span class="fc1 sc0"> </span><span class="fc1 sc0"> </span><span class="fc1 sc0"> </span><span class="fc1 sc0"> </span><span class="fc1 sc0"> </span><span class="fc1 sc0"> </span><span class="fc1 sc0"> </span><span class="fc1 sc0"> </span><span class="fc1 sc0"> </span><span class="fc1 sc0"> </span><span class="fc1 sc0"> </span><span class="fc1 sc0"> </span><span class="ff2"><span class="fc1 sc0"> </span></span></div><div class="t m0 x3 h4 y3 ff2 fs0 fc0 sc0 ls0 ws0"> </div><div class="t m0 x2 h4 y4 ff2 fs0 fc0 sc0 ls0 ws0"> </div><div class="t m0 x2 h5 y5 ff2 fs1 fc0 sc0 ls0 ws0"> <span class="_ _3"> </span> <span class="_ _4"> </span><span class="ff1">1 </span></div><div class="t m0 x4 h6 y6 ff3 fs2 fc0 sc0 ls0 ws0">How to<span class="_ _0"></span> <span class="_ _5"></span>Add a<span class="_ _0"></span> New System Call for Minix 3 </div><div class="t m0 x5 h3 y7 ff1 fs0 fc0 sc0 ls0 ws0">Karthick Jayar<span class="_ _0"></span>aman </div><div class="t m0 x6 h3 y8 ff1 fs0 fc0 sc0 ls0 ws0">Departm<span class="_ _0"></span>ent of Elect<span class="_ _2"></span>rical Engineering &amp; Computer <span class="_ _0"></span>Science </div><div class="t m0 x7 h3 y9 ff1 fs0 fc0 sc0 ls0 ws0">Syracuse Univer<span class="_ _0"></span>sity, Syracuse, New Yo<span class="_ _2"></span>rk </div><div class="t m0 x2 h4 ya ff2 fs0 fc0 sc0 ls0 ws0"> </div><div class="t m0 x2 h7 yb ff3 fs3 fc0 sc0 ls0 ws0">1.<span class="ff2"> <span class="_"> </span></span>Introdu<span class="_ _2"></span>c<span class="_ _0"></span>tion </div><div class="t m0 x2 h8 yc ff4 fs0 fc0 sc0 ls0 ws0"> </div><div class="t m0 x2 h8 yd ff4 fs0 fc0 sc0 ls0 ws0">Minix3 <span class="_ _6"></span>has <span class="_ _6"></span>the <span class="_ _6"></span>micro-kernel <span class="_ _6"></span>architecture.<span class="_ _0"></span> <span class="_ _6"></span>The <span class="_ _6"></span>micro-kernel <span class="_ _6"></span>handles <span class="_ _6"></span>interrupt<span class="_ _0"></span>s, <span class="_ _6"></span>provides </div><div class="t m0 x2 h8 ye ff4 fs0 fc0 sc0 ls0 ws0">basic <span class="_ _7"> </span>mechanisms <span class="_ _7"> </span>for<span class="_ _0"></span> <span class="_ _7"> </span>pr<span class="_ _0"></span>ocess<span class="_ _5"></span> <span class="_ _8"> </span>management, <span class="_ _7"> </span>implements <span class="_ _7"> </span>inter-pr<span class="_ _0"></span>ocess<span class="_ _5"></span> <span class="_ _8"> </span>communication, </div><div class="t m0 x2 h8 yf ff4 fs0 fc0 sc0 ls0 ws0">and <span class="_"> </span>perf<span class="_ _0"></span>orms <span class="_ _9"> </span>process <span class="_"> </span>scheduling. <span class="_ _9"> </span>F<span class="_ _0"></span>ilesys<span class="_ _2"></span>tem, <span class="_ _9"> </span>process <span class="_"> </span>managem<span class="_ _0"></span>ent, <span class="_ _9"> </span>networking, <span class="_ _9"> </span>and </div><div class="t m0 x2 h8 y10 ff4 fs0 fc0 sc0 ls0 ws0">other <span class="_"> </span>us<span class="_ _5"></span>er<span class="_ _0"></span>-services <span class="_ _7"> </span>ar<span class="_ _0"></span>e <span class="_ _8"> </span>available <span class="_ _8"> </span>from <span class="_"> </span>se<span class="_ _5"></span>par<span class="_ _0"></span>ate <span class="_ _8"> </span>servers <span class="_ _7"> </span>out<span class="_ _0"></span>side <span class="_ _7"> </span>t<span class="_ _0"></span>he <span class="_ _8"> </span>micro-kernel.<span class="_ _0"></span> <span class="_ _8"> </span>The </div><div class="t m0 x2 h8 y11 ff4 fs0 fc0 sc0 ls0 ws0">system <span class="_ _a"></span>calls <span class="_ _a"></span>h<span class="_ _0"></span>andled <span class="_ _a"></span>by <span class="_ _6"></span>these <span class="_ _a"></span>services <span class="_ _a"></span>are <span class="_ _6"></span>now <span class="_ _a"></span>pr<span class="_ _0"></span>ocessed <span class="_ _a"></span>out<span class="_ _0"></span>side <span class="_ _a"></span>the <span class="_ _6"></span>kernel. <span class="_ _6"></span>The <span class="_ _a"></span>kernel </div><div class="t m0 x2 h8 y12 ff4 fs0 fc0 sc0 ls0 ws0">supports <span class="_ _b"> </span>a <span class="_ _b"> </span>few <span class="_ _b"> </span>system-calls <span class="_ _b"> </span>and <span class="_ _b"> </span>these <span class="_ _b"> </span>are <span class="_ _b"> </span>called <span class="_ _b"> </span>system-tasks<span class="_ _2"></span>. <span class="_ _b"> </span>S<span class="_ _0"></span>ystems<span class="_ _2"></span>-tasks <span class="_ _b"> </span>are <span class="_ _c"> </span>more </div><div class="t m0 x2 h8 y13 ff4 fs0 fc0 sc0 ls0 ws0">like a hardware <span class="_ _0"></span>abstraction<span class="_ _5"></span>.<span class="_ _0"></span> </div><div class="t m0 x2 h8 y14 ff4 fs0 fc0 sc0 ls0 ws0"> </div><div class="t m0 x2 h8 y15 ff4 fs0 fc0 sc0 ls0 ws0">In <span class="_ _b"> </span>Minix3,<span class="_ _0"></span> <span class="_ _b"> </span>the <span class="_ _b"> </span>servers <span class="_ _b"> </span>handle <span class="_ _b"> </span>system <span class="_ _b"> </span>calls. <span class="_ _b"> </span>Adding <span class="_ _b"> </span>a <span class="_ _c"> </span>new <span class="_ _b"> </span>system <span class="_ _b"> </span>call <span class="_ _b"> </span>consists <span class="_ _b"> </span>of <span class="_ _b"> </span>two<span class="_ _0"></span> </div><div class="t m0 x2 h8 y16 ff4 fs0 fc0 sc0 ls0 ws0">steps: <span class="_ _6"></span>writing <span class="_ _b"> </span>a <span class="_ _6"></span>system-call <span class="_ _6"></span>handler <span class="_ _b"> </span>and <span class="_ _6"></span>writing <span class="_ _b"> </span>a <span class="_ _6"></span>user <span class="_ _d"> </span>library.<span class="_ _0"></span> <span class="_ _6"></span>System-call <span class="_ _d"></span>handler <span class="_ _d"></span>is <span class="_ _6"></span>a </div><div class="t m0 x2 h8 y17 ff4 fs0 fc0 sc0 ls0 ws0">function that <span class="_ _0"></span>is <span class="_ _0"></span>called in<span class="_ _0"></span> response t<span class="_ _0"></span>o <span class="_ _0"></span>a user<span class="_ _0"></span> requesti<span class="_ _0"></span>ng a sy<span class="_ _0"></span>stem call.<span class="_ _0"></span> Each <span class="_ _0"></span>system c<span class="_ _0"></span>all ha<span class="_ _0"></span>s </div><div class="t m0 x2 h8 y18 ff4 fs0 fc0 sc0 ls0 ws0">one <span class="_ _c"> </span>handler. <span class="_ _c"> </span>A <span class="_ _7"> </span>use<span class="_ _2"></span>r <span class="_ _c"> </span>libr<span class="_ _0"></span>ary <span class="_ _c"> </span>packages <span class="_ _b"> </span>the <span class="_ _c"> </span>parameters <span class="_ _c"> </span>f<span class="_ _0"></span>or <span class="_ _c"> </span>the <span class="_ _c"> </span>system <span class="_ _c"> </span>call <span class="_ _c"> </span>and <span class="_ _c"> </span>calls <span class="_ _c"> </span>th<span class="_ _0"></span>e </div><div class="t m0 x2 h8 y19 ff4 fs0 fc0 sc0 ls0 ws0">handler on <span class="_ _0"></span>the<span class="_ _5"></span> <span class="_ _0"></span>appropriate server. A user always invokes<span class="_ _5"></span> <span class="_ _0"></span>a system call using the libr<span class="_ _0"></span>ary. </div><div class="t m0 x2 h8 y1a ff4 fs0 fc0 sc0 ls0 ws0"> </div><div class="t m0 x2 h8 y1b ff4 fs0 fc0 sc0 ls0 ws0">The <span class="_ _6"></span>system-call <span class="_ _6"></span>handler <span class="_ _6"></span>should <span class="_ _6"></span>be <span class="_ _6"></span>placed <span class="_ _6"></span>in <span class="_ _6"></span>an <span class="_ _6"></span>appropriate <span class="_ _6"></span>server,<span class="_ _0"></span> <span class="_ _6"></span>which <span class="_ _6"></span>in <span class="_ _6"></span>turn <span class="_ _6"></span>would </div><div class="t m0 x2 h8 y1c ff4 fs0 fc0 sc0 ls0 ws0">process <span class="_ _d"></span>a <span class="_ _d"> </span>u<span class="_ _0"></span>ser <span class="_ _d"> </span>r<span class="_ _0"></span>eques<span class="_ _2"></span>t <span class="_ _d"> </span>by <span class="_ _b"> </span>invoking <span class="_ _b"> </span>the <span class="_ _d"> </span>matching <span class="_ _b"> </span>handler. <span class="_ _b"> </span>It <span class="_ _b"> </span>is <span class="_ _d"> </span>important <span class="_ _d"> </span>to <span class="_ _b"> </span>choose <span class="_ _d"> </span>the<span class="_ _0"></span> </div><div class="t m0 x2 h8 y1d ff4 fs0 fc0 sc0 ls0 ws0">correct <span class="_ _e"> </span>server <span class="_ _e"> </span>for <span class="_ _e"> </span>the <span class="_ _e"> </span>system-call. <span class="_ _e"> </span>For <span class="_ _e"> </span>instanc<span class="_ _0"></span>e, <span class="_ _e"> </span>if <span class="_ _e"> </span>the <span class="_ _e"> </span>syste<span class="_ _2"></span>m<span class="_ _0"></span> <span class="_ _e"> </span>call <span class="_ _e"> </span>should <span class="_ _e"> </span>update </div><div class="t m0 x2 h8 y1e ff4 fs0 fc0 sc0 ls0 ws0">filesystem <span class="_ _6"></span>or <span class="_ _6"></span>fproc <span class="_ _d"></span>data-structures, <span class="_ _6"></span>then <span class="_ _6"></span>the <span class="_ _6"></span>system-call <span class="_ _6"></span>handler <span class="_ _d"></span>should <span class="_ _6"></span>be <span class="_ _6"></span>placed <span class="_ _a"></span>i<span class="_ _0"></span>n <span class="_ _6"></span>the </div><div class="t m0 x2 h8 y1f ff4 fs0 fc0 sc0 ls0 ws0">FS (filesystem) server. </div><div class="t m0 x2 h8 y20 ff4 fs0 fc0 sc0 ls0 ws0"> </div><div class="t m0 x2 h8 y21 ff4 fs0 fc0 sc0 ls0 ws0">This <span class="_ _6"></span>document <span class="_ _6"></span>illustrates <span class="_ _6"></span>the <span class="_ _6"></span>method <span class="_ _6"></span>for<span class="_ _0"></span> <span class="_ _6"></span>adding <span class="_ _6"></span>a <span class="_ _6"></span>new <span class="_ _6"></span>sys<span class="_ _5"></span>tem <span class="_ _6"></span>call <span class="_ _d"></span>for <span class="_ _6"></span>Minix3 <span class="_ _6"></span>using <span class="_ _6"></span>an<span class="_ _0"></span> </div><div class="t m0 x2 h8 y22 ff4 fs0 fc0 sc0 ls0 ws0">example. <span class="_ _a"></span>We <span class="_ _0"></span>would <span class="_ _a"></span>impl<span class="_ _0"></span>ement<span class="_ _5"></span> <span class="_ _a"></span>a <span class="_ _a"></span>system-call <span class="_ _0"></span>handler <span class="_ _a"></span>do_printmessage() <span class="_ _0"></span>i<span class="_ _0"></span>n<span class="_ _2"></span> <span class="_ _a"></span>the <span class="_ _0"></span>F<span class="_ _0"></span>S <span class="_ _0"></span>server </div><div class="t m0 x2 h8 y23 ff4 fs0 fc0 sc0 ls0 ws0">that <span class="_ _a"></span>would <span class="_ _a"></span>simply <span class="_ _0"></span>pr<span class="_ _0"></span>int <span class="_ _a"></span>a <span class="_ _a"></span>mess<span class="_ _5"></span>ag<span class="_ _0"></span>e <span class="_ _a"></span>&#8220;I <span class="_ _a"></span>am <span class="_ _a"></span>a <span class="_ _a"></span>system <span class="_ _a"></span>call&#8221;. <span class="_ _a"></span>However,<span class="_ _0"></span> <span class="_ _a"></span>the <span class="_ _0"></span>method <span class="_ _a"></span>described<span class="_ _0"></span> </div><div class="t m0 x2 h8 y24 ff4 fs0 fc0 sc0 ls0 ws0">could <span class="_ _a"></span>be <span class="_ _6"></span>used <span class="_ _a"></span>for <span class="_ _6"></span>adding <span class="_ _a"></span>the <span class="_ _6"></span>handler <span class="_ _a"></span>t<span class="_ _0"></span>o <span class="_ _a"></span>any <span class="_ _6"></span>serve<span class="_ _0"></span>r. <span class="_ _6"></span>We <span class="_ _a"></span>would <span class="_ _6"></span>also <span class="_ _a"></span>add <span class="_ _a"></span>a <span class="_ _6"></span>user-l<span class="_ _0"></span>ibrary <span class="_ _6"></span>to<span class="_ _5"></span> </div><div class="t m0 x2 h8 y25 ff4 fs0 fc0 sc0 ls0 ws0">call the handler. </div><div class="t m0 x2 h8 y26 ff4 fs0 fc0 sc0 ls0 ws0"> </div><div class="t m0 x2 h7 y27 ff3 fs3 fc0 sc0 ls0 ws0">2.<span class="ff2"> <span class="_"> </span></span>Creating a Syste<span class="_ _0"></span>m-call Han<span class="_ _0"></span>dler </div><div class="t m0 x2 h4 y28 ff2 fs0 fc0 sc0 ls0 ws0"> </div><div class="t m0 x2 h8 y29 ff4 fs0 fc0 sc0 ls0 ws0">The <span class="_ _a"></span>source <span class="_ _0"></span>code<span class="_ _0"></span> <span class="_ _a"></span>for <span class="_ _a"></span>all <span class="_ _a"></span>s<span class="_ _0"></span>ervers <span class="_ _a"></span>are <span class="_ _a"></span>located <span class="_ _a"></span>at <span class="_ _a"></span>/usr/<span class="_ _0"></span>src/servers. <span class="_ _a"></span>Each <span class="_ _a"></span>server<span class="_ _0"></span> <span class="_ _a"></span>has <span class="_ _a"></span>a <span class="_ _a"></span>separate </div><div class="t m0 x2 h8 y2a ff4 fs0 fc0 sc0 ls0 ws0">directory. <span class="_"> </span>Filesystem <span class="_ _8"> </span>(FS) <span class="_"> </span>is <span class="_ _7"> </span>l<span class="_ _0"></span>ocated <span class="_ _8"> </span>at <span class="_ _8"> </span>/usr/src/servers/fs. <span class="_"> </span>Each <span class="_ _8"> </span>of <span class="_"> </span>the <span class="_ _7"> </span>s<span class="_ _0"></span>erver <span class="_"> </span>s<span class="_ _2"></span>ource </div><div class="t m0 x2 h8 y2b ff4 fs0 fc0 sc0 ls0 ws0">directories <span class="_"> </span>contain <span class="_"> </span>two <span class="_"> </span>files: <span class="_"> </span>table.c <span class="_"> </span>and <span class="_"> </span>prot<span class="_ _0"></span>o.h. <span class="_"> </span>T<span class="_ _0"></span>able.c <span class="_"> </span>contains <span class="_"> </span>definition <span class="_"> </span>for <span class="_"> </span>the </div><div class="t m0 x2 h8 y2c ff4 fs0 fc0 sc0 ls0 ws0">call_vec <span class="_ _6"></span>table. <span class="_ _6"></span>The <span class="_ _6"></span>call_vec <span class="_ _6"></span>table <span class="_ _6"></span>is <span class="_ _6"></span>an <span class="_ _6"></span>array <span class="_ _6"></span>of<span class="_ _0"></span> <span class="_ _a"></span>function <span class="_ _6"></span>pointers <span class="_ _6"></span>that <span class="_ _6"></span>is <span class="_ _6"></span>indexed <span class="_ _6"></span>by <span class="_ _6"></span>t<span class="_ _0"></span>he </div><div class="t m0 x2 h8 y2d ff4 fs0 fc0 sc0 ls0 ws0">system-call <span class="_ _f"> </span>number. <span class="_ _10"> </span>In <span class="_ _10"> </span>each <span class="_ _9"> </span>l<span class="_ _0"></span>ine, <span class="_ _f"> </span>t<span class="_ _0"></span>he <span class="_ _f"> </span>addres<span class="_ _2"></span>s <span class="_ _f"> </span>of <span class="_ _10"> </span>a <span class="_ _f"> </span>system-call <span class="_ _f"> </span>handler <span class="_ _10"> </span>function <span class="_ _f"> </span>is </div><div class="t m0 x2 h8 y2e ff4 fs0 fc0 sc0 ls0 ws0">ass<span class="_ _2"></span>igned to one <span class="_ _0"></span>entry in the table <span class="_ _0"></span>and<span class="_ _5"></span> <span class="_ _0"></span>the index of t<span class="_ _2"></span>he entry is <span class="_ _0"></span>the<span class="_ _5"></span> <span class="_ _0"></span>system-call number. </div><div class="t m0 x2 h8 y2f ff4 fs0 fc0 sc0 ls0 ws0"> </div><div class="t m0 x2 h8 y30 ff4 fs0 fc0 sc0 ls0 ws0"> </div></div></div><div class="pi" data-data='{"ctm":[1.568627,0.000000,0.000000,1.568627,0.000000,0.000000]}'></div></div> </body> </html>
评论
    相关推荐
    • Minix.rar
      此资料为minix源码及解读,对研究操作系统的人很有大帮助.
    • MINIX-File-System-analysis.rar
      MINIX File System的分支,而且它依然被维护,以与Linux文件系统的架构变化同步。从实用角度说,实在没有这个必要,但Linus Torvalds 还保留着它,或许Linus有点舍不得吧?从学习文件系统角度说,MINIX文件系统是...
    • Minix.zip
      Minix源代码 包含了Minix操作系统内核的所有代码,适合想要深入研究操作系统源码的人
    • TenDRA C/C++ for Minix-开源
      用于Minix的TenDRA C / C ++编译器
    • minix系统介绍.rar
      minix系统介绍.rarminix系统介绍.raminix系统介绍.rarrminix系统介绍.rar
    • minix-3.1.0-BOOKSRC
      minix_source_3.1.0 Minix源码,对应<操作系统:设计与实现>的版本,minix3官网取得
    • Minix操作系统源代码
      Minix之父Andrew S. Tanenbaum的经典之作《操作系统设计与实现》一书所附源代码
    • Minix 3.1.3 源代码
      网上应该有下载,我把一个文本格式和一个PDF格式的打包好了.有需要的童鞋可以下载来看看.学习操作系统的时候感觉还是很有用的
    • MINIX-File-System-analysis.pdf
      MINIX-File-System 文件系统分析,对想深入了解Linux内核的同志有极大的帮助
    • MINIX 3 操作系统内核的源码
      _____________________________________ ..\ my1\ |-Makefile makefile文件。 |-dasm.bat 用于将整个系统反汇编成汇编代码... |--system._call.c 系统调用定义在这里 ______________________________________