1 Star 0 Fork 0

fys/self-blog

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
index.html 17.44 KB
一键复制 编辑 原始数据 按行查看 历史
fys 提交于 2024-04-10 19:40 . Site updated: 2024-04-10 19:40:57
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Hexo</title>
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta property="og:type" content="website">
<meta property="og:title" content="Hexo">
<meta property="og:url" content="http://example.com/index.html">
<meta property="og:site_name" content="Hexo">
<meta property="og:locale" content="en_US">
<meta property="article:author" content="FYS">
<meta name="twitter:card" content="summary">
<link rel="alternate" href="/atom.xml" title="Hexo" type="application/atom+xml">
<link rel="shortcut icon" href="/favicon.png">
<link rel="stylesheet" href="/css/style.css">
<link rel="stylesheet" href="/fancybox/jquery.fancybox.min.css">
<meta name="generator" content="Hexo 7.1.1"></head>
<body>
<div id="container">
<div id="wrap">
<header id="header">
<div id="banner"></div>
<div id="header-outer" class="outer">
<div id="header-title" class="inner">
<h1 id="logo-wrap">
<a href="/" id="logo">Hexo</a>
</h1>
</div>
<div id="header-inner" class="inner">
<nav id="main-nav">
<a id="main-nav-toggle" class="nav-icon"><span class="fa fa-bars"></span></a>
<a class="main-nav-link" href="/">Home</a>
<a class="main-nav-link" href="/archives">Archives</a>
</nav>
<nav id="sub-nav">
<a class="nav-icon" href="/atom.xml" title="RSS Feed"><span class="fa fa-rss"></span></a>
<a class="nav-icon nav-search-btn" title="Search"><span class="fa fa-search"></span></a>
</nav>
<div id="search-form-wrap">
<form action="//google.com/search" method="get" accept-charset="UTF-8" class="search-form"><input type="search" name="q" class="search-form-input" placeholder="Search"><button type="submit" class="search-form-submit">&#xF002;</button><input type="hidden" name="sitesearch" value="http://example.com"></form>
</div>
</div>
</div>
</header>
<div class="outer">
<section id="main">
<article id="post-my-first-blog" class="h-entry article article-type-post" itemprop="blogPost" itemscope itemtype="https://schema.org/BlogPosting">
<div class="article-meta">
<a href="/blog/my-first-blog/" class="article-date">
<time class="dt-published" datetime="2024-04-10T11:03:20.000Z" itemprop="datePublished">2024-04-10</time>
</a>
</div>
<div class="article-inner">
<header class="article-header">
<h1 itemprop="name">
<a class="p-name article-title" href="/blog/my-first-blog/">my first blog</a>
</h1>
</header>
<div class="e-content article-entry" itemprop="articleBody">
<h2 id="一、编写task-struct-c"><a href="#一、编写task-struct-c" class="headerlink" title="一、编写task_struct.c"></a>一、编写task_struct.c</h2><figure class="highlight c"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#<span class="keyword">include</span> <span class="string">&lt;linux/kernel.h&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="keyword">include</span> <span class="string">&lt;linux/module.h&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="keyword">include</span> <span class="string">&lt;uapi/linux/sched.h&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="keyword">include</span> <span class="string">&lt;linux/init_task.h&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="keyword">include</span> <span class="string">&lt;linux/init.h&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="keyword">include</span> <span class="string">&lt;linux/fdtable.h&gt;</span></span></span><br><span class="line"></span><br><span class="line">MODULE_LICENSE(<span class="string">&quot;GPL&quot;</span>);</span><br><span class="line"></span><br><span class="line"><span class="type">static</span> <span class="type">int</span> __init <span class="title function_">print_pid</span><span class="params">(<span class="type">void</span>)</span></span><br><span class="line">&#123;</span><br><span class="line"><span class="class"><span class="keyword">struct</span> <span class="title">task_struct</span> *<span class="title">task</span>, *<span class="title">p</span>;</span></span><br><span class="line"><span class="class"><span class="keyword">struct</span> <span class="title">list_head</span> *<span class="title">pos</span>;</span></span><br><span class="line"><span class="type">int</span> count=<span class="number">0</span>;</span><br><span class="line">printk(<span class="string">&quot;printf process meaaage begin:\n&quot;</span>);</span><br><span class="line">task = &amp;init_task;</span><br><span class="line"></span><br><span class="line"></span><br><span class="line">list_for_each(pos,&amp;task-&gt;tasks)</span><br><span class="line">&#123;</span><br><span class="line">p = list_entry(pos,<span class="keyword">struct</span> task_struct,tasks);</span><br><span class="line">count++;</span><br><span class="line">printk(<span class="string">&quot;\n\n&quot;</span>);</span><br><span class="line">printk(<span class="string">&quot;pid:%d; state:%lx; prio:%d; static_prio:%d; parent&#x27;pid:%d;\n&quot;</span>,\</span><br><span class="line">p-&gt;pid,p-&gt;__state,p-&gt;prio,p-&gt;static_prio,(p-&gt;parent)-&gt;pid);</span><br><span class="line"></span><br><span class="line">&#125;</span><br><span class="line">printk(<span class="string">&quot;process number:%d\n&quot;</span>,count);</span><br><span class="line"> <span class="keyword">return</span> <span class="number">0</span>;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="type">static</span> <span class="type">void</span> __exit <span class="title function_">pid_exit</span><span class="params">(<span class="type">void</span>)</span></span><br><span class="line">&#123;</span><br><span class="line">printk(<span class="string">&quot;exiting...\n&quot;</span>);</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line">module_init(print_pid);</span><br><span class="line">module_exit(pid_exit);</span><br></pre></td></tr></table></figure>
<h2 id="二、编写Makefile"><a href="#二、编写Makefile" class="headerlink" title="二、编写Makefile"></a>二、编写Makefile</h2><figure class="highlight makefile"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br></pre></td><td class="code"><pre><span class="line"><span class="section">obj-m:=task_struct.o</span></span><br><span class="line"></span><br><span class="line">CURRENT_PATH := <span class="variable">$(<span class="built_in">shell</span> pwd)</span></span><br><span class="line">LINUX_KERNEL := <span class="variable">$(<span class="built_in">shell</span> uname -r)</span></span><br><span class="line">LINUX_KERNEL_PATH := /usr/src/linux-headers-<span class="variable">$(LINUX_KERNEL)</span></span><br><span class="line"></span><br><span class="line"><span class="section">all:</span></span><br><span class="line"> make -C <span class="variable">$(LINUX_KERNEL_PATH)</span> M=<span class="variable">$(CURRENT_PATH)</span> modules</span><br><span class="line"></span><br><span class="line"><span class="section">clean:</span></span><br><span class="line"> make -C <span class="variable">$(LINUX_KERNEL_PATH)</span> M=<span class="variable">$(CURRENT_PATH)</span> clean</span><br></pre></td></tr></table></figure>
<h2 id="三、编译内核"><a href="#三、编译内核" class="headerlink" title="三、编译内核"></a>三、编译内核</h2><p><img src="D:\blog\temp\source_posts\my-first-blog.assets\image-20240407144029913.png" alt="image-20240407144029913"></p>
<h2 id="四、添加内核模块"><a href="#四、添加内核模块" class="headerlink" title="四、添加内核模块"></a>四、添加内核模块</h2><p><img src="D:\blog\temp\source_posts\my-first-blog.assets\image-20240407144221858.png" alt="image-20240407144221858"></p>
<h2 id="五、打印内核信息"><a href="#五、打印内核信息" class="headerlink" title="五、打印内核信息"></a>五、打印内核信息</h2><p><img src="D:\blog\temp\source_posts\my-first-blog.assets\image-20240407144418972.png" alt="image-20240407144418972"></p>
<h2 id="六、拓展"><a href="#六、拓展" class="headerlink" title="六、拓展"></a>六、拓展</h2><ul>
<li><strong>pid</strong> 字段由内核分配,每个进程都有一个唯一的 pid。pid 通常用于标识进程,例如在 <code>ps</code> 命令的输出中。</li>
<li><strong>comm</strong> 字段通常存储可执行文件的文件名,但也可以存储其他信息,例如由 <code>prctl</code> 系统调用设置的进程名称。</li>
<li><strong>state</strong> 字段是一个位字段,用于表示进程的多个状态。例如,<code>TASK_RUNNING</code> 表示进程正在运行,<code>TASK_INTERRUPTIBLE</code> 表示进程可中断,<code>TASK_STOPPED</code> 表示进程已停止。</li>
<li><strong>prio</strong><strong>normal_prio</strong> 字段用于确定进程的调度顺序。优先级较高的进程将获得更多的 CPU 时间。</li>
<li><strong>cpus_ptr</strong> 字段指示进程可以运行的 CPU。这对于多核系统很有用,因为它允许内核将进程调度到空闲的 CPU 上。</li>
<li><strong>mm</strong><strong>active_mm</strong> 字段描述进程的地址空间。地址空间包含进程的可执行代码、数据和堆栈。</li>
<li><strong>fs</strong> 字段描述进程的文件系统根目录。</li>
<li><strong>signal</strong><strong>sighand</strong><strong>blocked</strong><strong>pending</strong> 字段用于管理进程的信号。</li>
<li><strong>stack</strong> 字段指向进程的内核栈。内核栈用于存储进程的局部变量和函数调用信息。</li>
<li><strong>sas_ss_sp</strong><strong>sas_ss_size</strong> 字段用于描述信号处理程序的备用堆栈。备用堆栈用于防止信号处理程序破坏进程的正常堆栈。</li>
</ul>
<p><img src="D:\blog\temp\source_posts\my-first-blog.assets\image-20240407150558798.png" alt="image-20240407150558798"></p>
</div>
<footer class="article-footer">
<a data-url="http://example.com/blog/my-first-blog/" data-id="clutpeg2o0000y4uydwvh3yss" data-title="my first blog" class="article-share-link"><span class="fa fa-share">Share</span></a>
<ul class="article-tag-list" itemprop="keywords"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/1/" rel="tag">1</a></li><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/2/" rel="tag">2</a></li></ul>
</footer>
</div>
</article>
<article id="post-hello-world" class="h-entry article article-type-post" itemprop="blogPost" itemscope itemtype="https://schema.org/BlogPosting">
<div class="article-meta">
<a href="/blog/hello-world/" class="article-date">
<time class="dt-published" datetime="2024-04-10T10:21:33.460Z" itemprop="datePublished">2024-04-10</time>
</a>
</div>
<div class="article-inner">
<header class="article-header">
<h1 itemprop="name">
<a class="p-name article-title" href="/blog/hello-world/">Hello World</a>
</h1>
</header>
<div class="e-content article-entry" itemprop="articleBody">
<p>Welcome to <a target="_blank" rel="noopener" href="https://hexo.io/">Hexo</a>! This is your very first post. Check <a target="_blank" rel="noopener" href="https://hexo.io/docs/">documentation</a> for more info. If you get any problems when using Hexo, you can find the answer in <a target="_blank" rel="noopener" href="https://hexo.io/docs/troubleshooting.html">troubleshooting</a> or you can ask me on <a target="_blank" rel="noopener" href="https://github.com/hexojs/hexo/issues">GitHub</a>.</p>
<h2 id="Quick-Start"><a href="#Quick-Start" class="headerlink" title="Quick Start"></a>Quick Start</h2><h3 id="Create-a-new-post"><a href="#Create-a-new-post" class="headerlink" title="Create a new post"></a>Create a new post</h3><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">$ hexo new <span class="string">&quot;My New Post&quot;</span></span><br></pre></td></tr></table></figure>
<p>More info: <a target="_blank" rel="noopener" href="https://hexo.io/docs/writing.html">Writing</a></p>
<h3 id="Run-server"><a href="#Run-server" class="headerlink" title="Run server"></a>Run server</h3><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">$ hexo server</span><br></pre></td></tr></table></figure>
<p>More info: <a target="_blank" rel="noopener" href="https://hexo.io/docs/server.html">Server</a></p>
<h3 id="Generate-static-files"><a href="#Generate-static-files" class="headerlink" title="Generate static files"></a>Generate static files</h3><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">$ hexo generate</span><br></pre></td></tr></table></figure>
<p>More info: <a target="_blank" rel="noopener" href="https://hexo.io/docs/generating.html">Generating</a></p>
<h3 id="Deploy-to-remote-sites"><a href="#Deploy-to-remote-sites" class="headerlink" title="Deploy to remote sites"></a>Deploy to remote sites</h3><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">$ hexo deploy</span><br></pre></td></tr></table></figure>
<p>More info: <a target="_blank" rel="noopener" href="https://hexo.io/docs/one-command-deployment.html">Deployment</a></p>
</div>
<footer class="article-footer">
<a data-url="http://example.com/blog/hello-world/" data-id="cluto161o0000jkuy2p743w64" data-title="Hello World" class="article-share-link"><span class="fa fa-share">Share</span></a>
</footer>
</div>
</article>
</section>
<aside id="sidebar">
<div class="widget-wrap">
<h3 class="widget-title">Tags</h3>
<div class="widget">
<ul class="tag-list" itemprop="keywords"><li class="tag-list-item"><a class="tag-list-link" href="/tags/1/" rel="tag">1</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/2/" rel="tag">2</a></li></ul>
</div>
</div>
<div class="widget-wrap">
<h3 class="widget-title">Tag Cloud</h3>
<div class="widget tagcloud">
<a href="/tags/1/" style="font-size: 10px;">1</a> <a href="/tags/2/" style="font-size: 10px;">2</a>
</div>
</div>
<div class="widget-wrap">
<h3 class="widget-title">Archives</h3>
<div class="widget">
<ul class="archive-list"><li class="archive-list-item"><a class="archive-list-link" href="/archives/2024/04/">April 2024</a></li></ul>
</div>
</div>
<div class="widget-wrap">
<h3 class="widget-title">Recent Posts</h3>
<div class="widget">
<ul>
<li>
<a href="/blog/my-first-blog/">my first blog</a>
</li>
<li>
<a href="/blog/hello-world/">Hello World</a>
</li>
</ul>
</div>
</div>
</aside>
</div>
<footer id="footer">
<div class="outer">
<div id="footer-info" class="inner">
&copy; 2024 FYS<br>
Powered by <a href="https://hexo.io/" target="_blank">Hexo</a>
</div>
</div>
</footer>
</div>
<nav id="mobile-nav">
<a href="/" class="mobile-nav-link">Home</a>
<a href="/archives" class="mobile-nav-link">Archives</a>
</nav>
<script src="/js/jquery-3.6.4.min.js"></script>
<script src="/fancybox/jquery.fancybox.min.js"></script>
<script src="/js/script.js"></script>
</div>
</body>
</html>
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/fang-yashen/self-blog.git
git@gitee.com:fang-yashen/self-blog.git
fang-yashen
self-blog
self-blog
master

搜索帮助