mirror of
https://github.com/rcore-os/rCore-Tutorial-v3.git
synced 2024-11-25 10:56:25 +04:00
13 lines
12 KiB
HTML
13 lines
12 KiB
HTML
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="generator" content="rustdoc"><meta name="description" content="Task management implementation"><title>os::task - Rust</title><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/SourceSerif4-Regular-46f98efaafac5295.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/FiraSans-Regular-018c141bf0843ffd.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/FiraSans-Medium-8f9a781e4970d388.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/SourceCodePro-Regular-562dcc5011b6de7d.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/SourceSerif4-Bold-a2c9cd1067f8b328.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/SourceCodePro-Semibold-d899c5a5c4aeb14a.ttf.woff2"><link rel="stylesheet" href="../../static.files/normalize-76eba96aa4d2e634.css"><link rel="stylesheet" href="../../static.files/rustdoc-fa3bb1812debf86c.css"><meta name="rustdoc-vars" data-root-path="../../" data-static-root-path="../../static.files/" data-current-crate="os" data-themes="" data-resource-suffix="" data-rustdoc-version="1.75.0-nightly (bf9a1c8a1 2023-10-08)" data-channel="nightly" data-search-js="search-5f5ec5419eadd0c9.js" data-settings-js="settings-74424d7eec62a23e.js" ><script src="../../static.files/storage-fec3eaa3851e447d.js"></script><script defer src="../../static.files/main-c5bd66d33317d69f.js"></script><noscript><link rel="stylesheet" href="../../static.files/noscript-5d8b3c7633ad77ba.css"></noscript><link rel="alternate icon" type="image/png" href="../../static.files/favicon-16x16-8b506e7a72182f1c.png"><link rel="alternate icon" type="image/png" href="../../static.files/favicon-32x32-422f7d1d52889060.png"><link rel="icon" type="image/svg+xml" href="../../static.files/favicon-2c020d218678b618.svg"></head><body class="rustdoc mod"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle">☰</button><a class="logo-container" href="../../os/index.html"><img class="rust-logo" src="../../static.files/rust-logo-151179464ae7ed46.svg" alt="logo"></a></nav><nav class="sidebar"><a class="logo-container" href="../../os/index.html"><img class="rust-logo" src="../../static.files/rust-logo-151179464ae7ed46.svg" alt="logo"></a><h2 class="location"><a href="#">Module task</a></h2><div class="sidebar-elems"><section><ul class="block"><li><a href="#modules">Modules</a></li><li><a href="#structs">Structs</a></li><li><a href="#constants">Constants</a></li><li><a href="#functions">Functions</a></li></ul></section></div></nav><main><div class="width-limiter"><nav class="sub"><form class="search-form"><span></span><input class="search-input" name="search" aria-label="Run search in the documentation" autocomplete="off" spellcheck="false" placeholder="Click or press ‘S’ to search, ‘?’ for more options…" type="search"><div id="help-button" title="help" tabindex="-1"><a href="../../help.html">?</a></div><div id="settings-menu" tabindex="-1"><a href="../../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../../static.files/wheel-7b819b6101059cd0.svg"></a></div></form></nav><section id="main-content" class="content"><div class="main-heading"><h1>Module <a href="../index.html">os</a>::<wbr><a class="mod" href="#">task</a><button id="copy-path" title="Copy item path to clipboard"><img src="../../static.files/clipboard-7571035ce49a181d.svg" width="19" height="18" alt="Copy item path"></button></h1><span class="out-of-band"><a class="src" href="../../src/os/task/mod.rs.html#1-124">source</a> · <button id="toggle-all-docs" title="collapse all docs">[<span>−</span>]</button></span></div><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Task management implementation</p>
|
||
<p>Everything about task management, like starting and switching tasks is
|
||
implemented here.</p>
|
||
<p>A single global instance of <a href="manager/struct.TaskManager.html" title="struct os::task::manager::TaskManager"><code>TaskManager</code></a> called <code>TASK_MANAGER</code> controls
|
||
all the tasks in the whole operating system.</p>
|
||
<p>A single global instance of <a href="processor/struct.Processor.html" title="struct os::task::processor::Processor"><code>Processor</code></a> called <code>PROCESSOR</code> monitors running
|
||
task(s) for each core.</p>
|
||
<p>A single global instance of <a href="pid/struct.PidAllocator.html" title="struct os::task::pid::PidAllocator"><code>PidAllocator</code></a> called <code>PID_ALLOCATOR</code> allocates
|
||
pid for user apps.</p>
|
||
<p>Be careful when you see <code>__switch</code> ASM function in <code>switch.S</code>. Control flow around this function
|
||
might not be what you expect.</p>
|
||
</div></details><h2 id="modules" class="small-section-header"><a href="#modules">Modules</a></h2><ul class="item-table"><li><div class="item-name"><a class="mod" href="context/index.html" title="mod os::task::context">context</a><span title="Restricted Visibility"> 🔒</span> </div><div class="desc docblock-short">Implementation of <a href="context/struct.TaskContext.html" title="struct os::task::context::TaskContext"><code>TaskContext</code></a></div></li><li><div class="item-name"><a class="mod" href="manager/index.html" title="mod os::task::manager">manager</a><span title="Restricted Visibility"> 🔒</span> </div><div class="desc docblock-short">Implementation of <a href="manager/struct.TaskManager.html" title="struct os::task::manager::TaskManager"><code>TaskManager</code></a></div></li><li><div class="item-name"><a class="mod" href="pid/index.html" title="mod os::task::pid">pid</a><span title="Restricted Visibility"> 🔒</span> </div><div class="desc docblock-short">Implementation of <a href="pid/struct.PidAllocator.html" title="struct os::task::pid::PidAllocator"><code>PidAllocator</code></a></div></li><li><div class="item-name"><a class="mod" href="processor/index.html" title="mod os::task::processor">processor</a><span title="Restricted Visibility"> 🔒</span> </div><div class="desc docblock-short">Implementation of <a href="processor/struct.Processor.html" title="struct os::task::processor::Processor"><code>Processor</code></a> and Intersection of control flow</div></li><li><div class="item-name"><a class="mod" href="switch/index.html" title="mod os::task::switch">switch</a><span title="Restricted Visibility"> 🔒</span> </div><div class="desc docblock-short">Wrap <code>switch.S</code> as a function</div></li><li><div class="item-name"><a class="mod" href="task/index.html" title="mod os::task::task">task</a><span title="Restricted Visibility"> 🔒</span> </div><div class="desc docblock-short">Implementation of <a href="task/struct.TaskControlBlock.html" title="struct os::task::task::TaskControlBlock"><code>TaskControlBlock</code></a></div></li></ul><h2 id="structs" class="small-section-header"><a href="#structs">Structs</a></h2><ul class="item-table"><li><div class="item-name"><a class="struct" href="struct.INITPROC.html" title="struct os::task::INITPROC">INITPROC</a></div><div class="desc docblock-short">Globle process that init user shell</div></li><li><div class="item-name"><a class="struct" href="struct.KernelStack.html" title="struct os::task::KernelStack">KernelStack</a></div><div class="desc docblock-short">Kernelstack for app</div></li><li><div class="item-name"><a class="struct" href="struct.PidAllocator.html" title="struct os::task::PidAllocator">PidAllocator</a></div><div class="desc docblock-short">Pid Allocator struct</div></li><li><div class="item-name"><a class="struct" href="struct.PidHandle.html" title="struct os::task::PidHandle">PidHandle</a></div><div class="desc docblock-short">Bind pid lifetime to <code>PidHandle</code></div></li><li><div class="item-name"><a class="struct" href="struct.Processor.html" title="struct os::task::Processor">Processor</a></div><div class="desc docblock-short">Processor management structure</div></li><li><div class="item-name"><a class="struct" href="struct.TaskContext.html" title="struct os::task::TaskContext">TaskContext</a></div><div class="desc docblock-short">task context structure containing some registers</div></li><li><div class="item-name"><a class="struct" href="struct.TaskManager.html" title="struct os::task::TaskManager">TaskManager</a></div><div class="desc docblock-short">A array of <code>TaskControlBlock</code> that is thread-safe</div></li></ul><h2 id="constants" class="small-section-header"><a href="#constants">Constants</a></h2><ul class="item-table"><li><div class="item-name"><a class="constant" href="constant.IDLE_PID.html" title="constant os::task::IDLE_PID">IDLE_PID</a></div><div class="desc docblock-short">pid of usertests app in make run TEST=1</div></li></ul><h2 id="functions" class="small-section-header"><a href="#functions">Functions</a></h2><ul class="item-table"><li><div class="item-name"><a class="fn" href="fn.add_initproc.html" title="fn os::task::add_initproc">add_initproc</a></div><div class="desc docblock-short">Add init process to the manager</div></li><li><div class="item-name"><a class="fn" href="fn.add_task.html" title="fn os::task::add_task">add_task</a></div><div class="desc docblock-short">Interface offered to add task</div></li><li><div class="item-name"><a class="fn" href="fn.current_task.html" title="fn os::task::current_task">current_task</a></div><div class="desc docblock-short">Get running task</div></li><li><div class="item-name"><a class="fn" href="fn.current_trap_cx.html" title="fn os::task::current_trap_cx">current_trap_cx</a></div><div class="desc docblock-short">Get the mutable reference to trap context of current task</div></li><li><div class="item-name"><a class="fn" href="fn.current_user_token.html" title="fn os::task::current_user_token">current_user_token</a></div><div class="desc docblock-short">Get token of the address space of current task</div></li><li><div class="item-name"><a class="fn" href="fn.exit_current_and_run_next.html" title="fn os::task::exit_current_and_run_next">exit_current_and_run_next</a></div><div class="desc docblock-short">Exit the current ‘Running’ task and run the next task in task list.</div></li><li><div class="item-name"><a class="fn" href="fn.fetch_task.html" title="fn os::task::fetch_task">fetch_task</a></div><div class="desc docblock-short">Interface offered to pop the first task</div></li><li><div class="item-name"><a class="fn" href="fn.pid_alloc.html" title="fn os::task::pid_alloc">pid_alloc</a></div><div class="desc docblock-short">Allocate a pid from PID_ALLOCATOR</div></li><li><div class="item-name"><a class="fn" href="fn.run_tasks.html" title="fn os::task::run_tasks">run_tasks</a></div><div class="desc docblock-short">The main part of process execution and scheduling
|
||
Loop <code>fetch_task</code> to get the process that needs to run, and switch the process through <code>__switch</code></div></li><li><div class="item-name"><a class="fn" href="fn.schedule.html" title="fn os::task::schedule">schedule</a></div><div class="desc docblock-short">Return to idle control flow for new scheduling</div></li><li><div class="item-name"><a class="fn" href="fn.suspend_current_and_run_next.html" title="fn os::task::suspend_current_and_run_next">suspend_current_and_run_next</a></div><div class="desc docblock-short">Suspend the current ‘Running’ task and run the next task in task list.</div></li><li><div class="item-name"><a class="fn" href="fn.take_current_task.html" title="fn os::task::take_current_task">take_current_task</a></div><div class="desc docblock-short">Take the current task,leaving a None in its place</div></li></ul></section></div></main></body></html> |